I'm trying to get HDMI to analog audio output switching when the HDMI cable is plugged or unplugged.
I have a working script that can detect if the HDMI output is plugged or not and switch pulseaudio to the correct setting:
if [ /sys/class/drm/card0-HDMI-A-1/status == "connected" ]; then
notify-send -u normal -t 500 -i gnome-sound-properties "HDMI On" "Sound to HDMI"
pacmd "set-card-profile 0 output:hdmi-stereo"
notify-send -u normal -t 500 -i gnome-sound-properties "HDMI Off" "Sound to Internal"
pacmd "set-card-profile 0 output:analog-stereo"
additionally I have in the udev a rule that triggers when the HDMI is plugged or unplugged:
SUBSYSTEM=="drm", ACTION=="change", RUN+="/bin/bash /etc/pulse/hdmi-switch"
Unfortunatly the first script only works if executed as the logged in user. Not when run as root. Does anybody have an idea how to get this combination working or how to get pulseaudio to switch the audio output when HDMI is (un-)plugged?
Last edited by wabi (2012-03-21 20:45:38)
I know this is an old post, but I have the same problem. Of cause I tried it with 'sudo -u'.
me$ sudo -u me $command
me$ sudo -E -u me $command
works. But I didn't find variables related to pulse in my enovirenment.
Any suggestions (I don't even know what to search for right now)?
Last edited by hiob (2013-02-02 15:24:01)