Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

To switch to HDMI audio output (of monitor) and back to normal audio output from system audio jack (for headphones, as my monitor doesn't have audio out), I find myself opening up sound preferences and selecting the right channel everytime. Is there any way I can create a toggle button in the panel or assign some shortcut key to toggle since I do the switching so often.

:aplay -l 
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: STAC92xx Analog [STAC92xx Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 3: HDMI 0 [HDMI 0]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 7: STAC92xx Digital [STAC92xx Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

enter image description here

share|improve this question
+1 It would be awesome if I could switch to the correct HDMI display output mode and sound mode in one keypress. – Kit Menke Nov 30 '11 at 2:10
What would be better yet is if when it detects this HDMI/Display Port audio channel it would switch it automatically. This is what docking is for. I seem to remember some docking code a while ago that will change configuration based on certain hardware IDs (MAC). Anyone know what that is called again? – Elijah Lynn Jan 15 '14 at 14:33

With pulseaudio we are able to select the output sink from the command line:

pacmd set-default-sink "SINKNAME"

This command can be used in a launcher, script or even assigned to a keyboard shortcut for fast switching between different sinks. Please replace "SINKNAME" by the name or number of your desired sink. A list of known sinks with their associated numbers and names is given by the command:

pacmd list-sinks

Note: Changing the output sink through the command line interface can only take effect if stream target device reading is disabled. This can be done by editing the corresponing line in /etc/pulse/ to:

load-module module-stream-restore restore_device=false

Alternatively we could run pulseaudio to simultaneously output sound to the internal audio device, and to the hdmi-device by running paprefs Install paprefs with the option to add a virtual output device:


share|improve this answer
pacmd set-default-sink "alsa_output.pci-0000_00_1b.0.analog-stereo" and pacmd set-default-sink "alsa_output.pci-0000_00_1b.0.hdmi-stereo" works only after selecting the corresponding profile in Sound Preferences. If I am having HDMI set and I run the pacmd command for analog stereo, I'm getting the eror Sink alsa_output.pci-0000_00_1b.0.analog-stereo does not exist. But if I manually select the profile from Sound Preferences GUI and run the same command, I am not getting the error. So it is not helping to switch. – iJeeves May 10 '11 at 21:39
@iJeeves: see edit for update. – Takkat May 21 '11 at 21:49
Similar issue. If I run the command it visually will change it in the GUI but the sound does not redirect. I have to manually toggle it in the GUI for it to work. Any ideas? – Elijah Lynn Jan 15 '14 at 14:57
@ElijahLynn: You may also have to move the stream:… – Takkat Jan 15 '14 at 15:53
@Takkat: I didn't try it yet but that looks to be the exact issue I was having. Thanks so much! – Elijah Lynn Jan 15 '14 at 20:34

I found this very annoying myself and wrote a script to toggle the output:


CURRENT_PROFILE=$(pacmd list-cards | grep "active profile" | cut -d ' ' -f 3-)

if [ "$CURRENT_PROFILE" = "<output:hdmi-stereo+input:analog-stereo>" ] ; then
        pacmd set-card-profile 0 "output:analog-stereo+input:analog-stereo"
        pacmd set-card-profile 0 "output:hdmi-stereo+input:analog-stereo"        

and then bound an unused key on my keyboard to execute it (see How to bind custom commands to keyboard shortcuts?)

share|improve this answer

If you are using Gnome Shell instead of Unity you can install the extension below. You'll then be able to switch from the volume short-cut in the top panel.

share|improve this answer

Since there is only one soundcard visible in the screenshot, I think the output of this soundcard should be switched.

For example: I have a Notebook with one integrated soundcard, but it has a digital output (SPDIF) when docked.

So what I wanted to do is switch the active output or "Profile" in pulseaudio.

I found the commands that do exactly that:

pacmd set-card-profile 0 output:analog-stereo
pacmd set-card-profile 0 output:iec958-stereo+input:analog-stereo

What I did to get the correct names for my desired output-setting--here, digital output, but analog (micro) input--was:

pacmd list | grep output
share|improve this answer

I've been trying to find a solution to this problem as well. As of Ubuntu 11.04 this does not seem to be possible directly, I only found this guide to add both HDMI and Analog as separate outputs, so pacmd shows 3 sinks now. Then it is possible to switch between sinks using the above commands. (see also)

But apparently Ubuntu 11.11 will get a PulseAudio with jack detection system. According to the website below, David Henningsson has coded a detection via udev so pulse audio automatically gets switched to the last added output, including switching between different profiles of the same soundcard (as is the case with your and my setup). (see here)

So I'm hoping this will work, when I try the final version next Friday.

share|improve this answer

Is there any way I can create a toggle button in the panel

I wrote a indicator applet that lets you switch the sound output (see screenshot).


share|improve this answer
Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Warren Hill Dec 21 '13 at 13:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.