Switch Pulse to use external USB sound device only if connected


If you have a laptop with typical feeble speakers, and a usb audio, then you might like to hear sound through the USB sound device when you have your external sound device connected.

Simply right-click the panel’s loudspeaker icon > Sound Preferences > Output and click on the radio button for your external device. Every time!

You can automate this by editing /etc/pulse/default.da but there is a better way:

In your home directory, create - if necessary - ~/.config/pulse/default.pa containing:

.include /etc/pulse/default.pa
load-module module-switch-on-connect

Then either reboot or run pulseaudio -k && pulseaudio --start to enable.

Ought to be the default action really … [ Source: ]


Ahh … It - auto selecting the usb device - is now the default action in 17.10 :sunglasses:

So this extra file is not need in 17.10, but worse … including the above will cause your pulseaudio code to not load at all ! :cry: Immediately after an install or upgrade there appears to be no file /etc/pulse/default.da, until pulseaduio runs first time, so the hack fails and pulseaudio is not able to load.

Hack should probably be something like:

if [ -f /etc/pulse/default.pa ]; then
    .include /etc/pulse/default.pa
    load-module module-switch-on-connect

But probably best to just delete it and upgrade to 17.10! :slight_smile:


Just a note to say that this also automatically connects bluetooth headphones in UM16.04.