16

I have a Bose Soundlink external audio device, which I use to stream music from my computer to my stereo. Ubuntu recognizes the device, but does not automatically use it. In order to get PulseAudio to use it for output, I have to manually choose it in the 'Output' tab in 'Sound settings'.

I would like PulseAudio to always prefer an external device over the internal, if one is available. Is there a way to accomplish this?

3 Answers 3

25

Also of use, is loading the module module-switch-on-connect. If you add the line:

load-module module-switch-on-connect

to /etc/pulse/default.pa (as su, of course), this should happen automatically without having to call a script.

The documentation for module-switch-on-connect has a more detailed description of how this works.

3
  • 3
    Thanks! That's an elegant solution to the problem. To test it: $ pactl load-module module-switch-on-connect
    – iElectric
    Commented Sep 30, 2014 at 17:29
  • 1
    Works great with my USB DAC and Linux Mint 18 Sarah
    – alfonx
    Commented Mar 8, 2017 at 7:20
  • Works with Sims4 USB headset+mic on Linux Mint 18.3 Sylvia Commented Mar 3, 2018 at 16:44
6

In theory, this should be handled by 'PulseAudio Volume Control'. There is a button to select a device as the default device, though imho poorly titled as 'Set as fallback'. More info about this feature here: http://ubuntuguide.org/wiki/Ubuntu_Oneiric_Hardware

Unfortunately the feature doesn't work. As soon as a USB audio device is unplugged the setting as default device is annoyingly forgotten, despite the fact that all the other settings such as volume, balance, etc. are retained next time the device is plugged in. In your case, if the device is not being removed this feature may actually work for you. If you are missing the app, just install the package 'pavucontrol'

I use a USB headset for calling and had to make a script using 'pacmd' to enable or disable it as needed to avoid going through the GUI, This allowed me to to just add a few launcher items to switch back and forth as needed. In my case, my script to enable the headset is:

#!/bin/bash
pacmd "set-default-sink alsa_output.usb-Logitech_Logitech_USB_Headset-00-Headset.analog-stereo"
pacmd "set-default-source alsa_input.usb-Logitech_Logitech_USB_Headset-00-Headset.analog-mono"

And to revert to my internal audio:

#!/bin/bash
pacmd "set-default-sink alsa_output.usb-Logitech_Logitech_USB_Headset-00-Headset.analog-stereo"
pacmd "set-default-source alsa_input.usb-Logitech_Logitech_USB_Headset-00-Headset.analog-mono"

'pacmd' is fairly easy to use, just run it from terminal and enter 'help' for more info.

4
  • 1
    Also worthy of note, I've switched to a KDE based distro (NetRunner) and audio device preferences are handled much better, even to the point of using different default devices for different application types (communication, multimedia, etc).
    – Veazer
    Commented May 9, 2013 at 19:14
  • 1
    "though imho poorly titled as 'Set as fallback'." Good point +1 Commented Feb 3, 2017 at 1:13
  • @Veazer Isn't Set as Fallback suppose to make PulseAudio use this device when the "main" device fails?
    – cprn
    Commented Aug 7, 2017 at 11:54
  • I had assumed that ‘Set as Fallback’ meant ‘set as default’ but I don’t think that’s true. The value in /~/.config/pulse/[longnumber]-default-sink is different and when I start a new program it uses that value in that file, not the fallback. Commented Jul 29, 2020 at 6:57
2

I had a similar answer to what Sam Whitlock said, except I had to edit the file default.pa in ~/.config/pulse. Just adding the load-module module-switch-on-connect worked!

Running Ubuntu 17.04 with a JieLi AC4100/IQ Sound Bluetooth Headset (using USB though).

You must log in to answer this question.

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