I use my laptop with an external monitor which has speakers. When the monitor is attached through HDMI I can switch (using the GUI: Sound Setting --> Hardware) between the normal laptop audio output and the monitor output.
I repeat this procedure a lot of time and I started to wonder if I can automate it or, anyway, execute it in a faster way using the shell.
My distro is Ubuntu 12.04 with gnome 3.
I tried using pacmd, but list-sinks gives me only the device I'm currently using:
pacmd list-sinks | grep name: name: <alsa_output.pci-0000_00_1b.0.hdmi-stereo>
After a switch from GUI:
pacmd list-sinks | grep name: name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
And if I try to change it I get:
pacmd set-default-sink alsa_output.pci-0000_00_1b.0.hdmi-stereo Welcome to PulseAudio! Use "help" for usage information. Sink alsa_output.pci-0000_00_1b.0.hdmi-stereo does not exist.