You are not logged in.

#1 2012-03-21 20:35:24

Registered: 2005-04-04
Posts: 61

HDMI switching pulseaudio output with udev

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:

#! /bin/bash
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)


#2 2013-02-02 15:06:42

Registered: 2007-12-15
Posts: 19

Re: HDMI switching pulseaudio output with udev

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

fails, while

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)


Board footer

Powered by FluxBB