I have been working in a script to change audio output when you (dis)connect am HDMI screen/TV. Basically it uses UDEV to check any change in the connection and acts accordingly.
Everything works fine except one thing: I can't use notify-send
to warn about the change. I use the following code (output
is just a wrapper to subprocess.check_output
):
output("sudo -u {0} notify-send "{1}" "{2}"".format(user, title, message))
but I don get any notification at all.
What is really odd is that if I run hdmi_sound_toggle
(as a normal user or with sudo
) everything works just fine!
So what could be the problem here? There is any better way to present a notification than with notify-send
?