16

One of the first things I noticed from upgrading from 16.04 to 18.04 is that every time I plugin earbuds I get this prompt to choose an audio device:

select audio device

Can I get Ubuntu to pick Headphones automatically? It's not in Sound Settings.

2 Answers 2

2
+150

Gnome developers have been talking about this problem for over a year:

The person making the request states:

Here's my drive-by-design thoughts:

The broad answer is indeed NOT to ask. If I explicitly plug in a device, I expect the sound to come out of it. There is an immediate direct interaction happening. Even if there are scenarios where this is not the case, asking every time you plug in an unknown device makes a bad common case experience. Of course there will be a ginormous long tail of special use cases.

Someone else rationalizes the reason for asking:

If you have a plug that can be a microphone or a washing machine and you can't tell which, I can't think of any other way but ask. :)

The last comment a developer concedes the pop-up window is poorly designed:

Oh, seems like you're right indeed: The first time I plug in a headphone, after a few seconds the output gets muted, while the dialog shows way before that for some reason (those seconds could probably already destroy a microphone), and every time after that, audio just doesn't get muted and continues while the dialog is visible. Also I'm seeing that sometimes we fail to show the dialog if the headphone is plugged in rather carefully (the loose connection seems to trigger the dialog multiple times). So we should either fix those issues or maybe consider those bug a "field test", since so far nobody complained about a broken microphone to us ;)

With some programming you could monitor for new windows being opened on your screen every two or three seconds. If the offending window opens you can send a mouse click to automatically select the headphones. I do this for example with some windows that have slide in bubble messages that lead to undesired advertising sites.

Another option would be to get the program name for the offending window and replace it with a new program that does nothing but unmute the sound.

In either case, unless you have some free time and the skills yourself, you will need to wait for a developer to create something.


There is something you can quickly try with no guarantee of success. There is a pulseaudio feature called module-switch-on-connect that enables automatic switching of an audio device on connection. To test if this works issue the following command in a terminal:

pacmd load-module module-switch-on-connect

Now plug in your headphones. If that works make it permanent by adding the following line to your /etc/pulse/default.pa:

load-module module-switch-on-connect

save the file and it will work on future reboots.

0

The following extension works well (tested on Ubuntu 22.04 which has Gnome 42.1): https://extensions.gnome.org/extension/3928/auto-select-headset/

You can install on the command line using the following (although you should first check if there's an updated version). Note that there is a line that restarts your gnome-shell session. You might prefer to just manually log off and log on, or to restart your computer rather than use that line. Up to you.

# download the extension
wget "https://extensions.gnome.org/extension-data/autoselectheadsetjosephlbarnett.github.com.v5.shell-extension.zip" &&
# install it
gnome-extensions install autoselectheadsetjosephlbarnett.github.com.v5.shell-extension.zip &&
# this is needed to refresh the available extensions.
killall -3 gnome-shell
# now enable the extension
gnome-extensions enable [email protected]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .