The problem: When you log in, Gnome picks whatever it damn pleases to make the active audio device(s). In my situation this was a little used but electrically problematic (bad grounding caused it to introduce an annoying hum) Dell Sound Bar. I fiddled with the gui interfaces (both Gnome's built-in and the add-on pavucontrol), with no success.
NOTE: No longer using this as I've moved on to Ubuntu 22.04 with pipewire. I'm back to working with pavucontrol to try keeping things under control.
Some brief notes to bring together what I've personally found to work.
The definitive thread on askubuntu is here:
https://askubuntu.com/questions/1038490/how-do-you-set-a-default-audio-output-device-in-ubuntu-18-04
This contains the answer(s), but in a disjointed way.
Here's what worked for me:
- Get the names of your audio devices loading by running
pactl list short sinks
(for me this would includealsa_output.pci-0000_00_1f.3.analog-stereo
, my built-in audio). - Create a new command with Startup Applications called "Set Default Audio Output" and
enter this as the Command:
pactl set-default-sink <device name>
. In my case:
pactl set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo
- Save and exit Startup Applications and log out.
- Log back in and verify that your desired audio device is now active (Gnome settings sound applet or pavucontrol will show this).
While normally I'd prefer to run something like this from .bashrc or .profile, I opted for a Startup Applications command because it launches with Gnome, and so won't get bigfooted by whatever settings the damned gui decides to impose.
As I was going through this exercise, I couldn't help but think I'd been through this kind of struggle with an operating environment before. Then I remembered. Right. Windows 95 (and every Windows since).
NOTE: The favoritism shown by PulseAudio to USB audio devices is no mystery. That's driven, among other things, by line 37 in the default /etc/pulse/default.pa (the whole section in context):
35 ### Use hot-plugged devices like Bluetooth or USB automatically (LP: #1702794)
36 .ifexists module-switch-on-connect.so
37 load-module module-switch-on-connect
38 .endif
Anyone trying to control Pulse's behavior at the system, rather than user, level should comment that line out. For user level fixes like the one above it can be left in place (which is a relief because changes there could be overwritten by future updates).
NOTE: If you're thinking about doing PCI passthrough with an Intel CPU having onboard graphics (e.g. HD530 on a 6th generation i5 or i7) you'll most likely have to blacklist the i915 module. Doing that may also make the onboard audio inaccessible on boot, mooting the above trick. You'll probably be able to switch to onboard audio after logging in, but that might compromise your ability to passthrough GPU. As always, YMMV. The results I observered were on a 3 year-old i5-6500 in an Asus PRIME B250M-C/CSM. And no, I ultimately wasn't able to get passthrough to work for... reasons.
Curious to know what the result of running
pactl list short sinks
on your system was and if you substituted what it showed for my example device? I'm moved on to Ubuntu 22.04, which uses pipewire under the covers, so I don't use this method any more. I've been reduced to using pavucontrol to simply shut everything down except for my audio interface (which shows up asalsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo-output
). We'll see how long that holds.