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. EDIT: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-stereoWelcome to PulseAudio! Use help for usage information.Sink alsa_output.pci-0000_00_1b.0.hdmi-stereo does not exist.
How can I switch between different audio output hardware using the shell?
shell;ubuntu;audio;pulseaudio
In this case the card is always the same. What is changing between a switch and another is the card-profile.So the solution which actually worked is: pacmd set-card-profile <cardindex> <profilename>In my case I found all the card profiles with:pacmd list-cardsAnd after I can switch between monitor and laptop speakers with:pacmd set-card-profile 0 output:hdmi-stereoAnd:pacmd set-card-profile 0 output:analog-stereo+input:analog-stereoWhere 0 is the index of the card:pacmd list-cardsWelcome to PulseAudio! Use help for usage information.>>> 1 card(s) available.    index: 0    name: <alsa_card.pci-0000_00_1b.0>And finally, in order to make the switch faster, I set up two alias in my .bashrc file:alias audio-hdmi='pacmd set-card-profile 0 output:hdmi-stereo+input:analog-stereo'alias audio-laptop='pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo'This way I can switch between audio from the monitor or from the laptop (headphones) typing in the shell: audio-hdmi or audio-laptop