Ubuntu – Auto-switch audio to HDMI when HDMI monitor/receiver plugged into laptop

hdmipulseaudiosoundudev

I have a laptop with an HDMI port. While we're homeless and staying with friends I've been plugging it into their surround sound receiver with an HDMI cable. To get sound working I have to open up the sound settings jobby and switch the hardware profile from "Analogue Stereo Output" to "Digital Stereo (HDMI) Output" to have sound coming from the surround sound instead of the laptop's mincey speakers.

I have to do the reverse when I unplug it to get sound coming out of the speakers.

I'm getting a little bored of doing this. I'd like to script this. I have seen this question and its answer but pacmd list-sinks only shows one sink when the sound profile drop down shows several options.

And is there a udev event I could hook this into so it can run the script whenever the HDMI status changes?

Best Answer

In Ubuntu 11.10 pulseaudio will recognize when you plug hdmi (or phone jack) and will make the switch automatically.

See this:

http://voices.canonical.com/david.henningsson/?p=15

Related Question