wolfgang ziegler


„make stuff and blog about it“

How to Keep the Default Audio Devices from Changing on Ubuntu

June 23, 2020

It's the year 2020 - in the top ten of our major tech challenges, we still have Linux and its audio settings.

The Problem

More specifically, it seems to be impossible to correctly remember the settings for audio input and output devices across reboots.

Ubuntu Audio Settings

This screenshot shows my desired configuration. From a couple of possible input and output devices, this is want I want to use. However, after each reboot those settings are changing and resetting - apparently at random.

A Solution

Disclaimer: I'm running Ubuntu 20.04 and the following steps work for me. As usual, your mileage may vary.

This is the Ubuntu version I am currently using and where the following steps worked.

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal

First, let's get a list of the available audio output devices (sinks) using the pactl command:

$ pactl list short sinks
1	alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1	module-alsa-card.c	s16le 2ch 44100Hz	IDLE
2	alsa_output.usb-FongLun_AmazonBasics_USB_Conference_Mic_201802-00.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	IDLE
3	alsa_output.pci-0000_02_00.0.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	RUNNING
4	alsa_output.pci-0000_00_1f.3.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	IDLE

Then do the same for the input devices (sources):

$ pactl list short sources
1	alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1.monitor	module-alsa-card.c	s16le 2ch 44100Hz	IDLE
2	alsa_input.usb-Microsoft_Microsoft___LifeCam_HD-5000-02.mono-fallback	module-alsa-card.c	s16le 1ch 44100Hz	IDLE
3	alsa_output.usb-FongLun_AmazonBasics_USB_Conference_Mic_201802-00.analog-stereo.monitor	module-alsa-card.c	s16le 2ch 44100Hz	IDLE
4	alsa_input.usb-FongLun_AmazonBasics_USB_Conference_Mic_201802-00.analog-stereo	module-alsa-card.c	s16le 2ch 44100Hz	IDLE
5	alsa_output.pci-0000_02_00.0.analog-stereo.monitor	module-alsa-card.c	s16le 2ch 44100Hz	IDLE
6	alsa_output.pci-0000_00_1f.3.analog-stereo.monitor	module-alsa-card.c	s16le 2ch 44100Hz	IDLE

Now, using the set-default-sink and set-default-source options of the pactl command, we can set the default input and output devices. This can either be done using the number or the device name (I recommend working with device names however, since those numbers seem to be changing across reboots).

Example:

$ pactl set-default-source alsa_output.pci-0000_00_1f.3.analog-stereo
$ pactl set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo

When trying out this commands with different sources and sinks, the result should be immediately reflected in the Audio Settings dialog.

Making the Solution Permanent

Note that these settings are volatile and won't survive a reboot of your PC. To make those settings persistent (well, kind of) I simple added those pactl set-default... instructions to my ~/.bashrcfile - problem solved.