I couldn't get the solution @singrium proposed to persist on Ubuntu 19.10. It worked with device numbers in /etc/pulse/default.pa but as I connected for example my headset device numbers were changing and things stopped working. It didn't work with device names in /etc/pulse/default.pa.
The simple workaround I found is adding the pactl set default sink command in startup applications.
Run: pactl list short sinks
Note the device name you want to use as default
Try to run: pactl set-default-sink <Your_Device_Name>
This should work without giving you an error message.
Open the application "Startup Applications" (Should be preinstalled on Ubuntu)
Click on "Add"
Give your startup item a name
Copy your command from above into the command field: pactl set-default-sink 'Your-Device-Name'
Click on "Add".
You are now good to go. Your default audio device will be set on each boot and as such be persistent. If you want to change the default device simply edit the device name in startup applications command.
If you switch sinks a lot, you can use fzf to select one via the command line and make it the default:
pactl set-default-sink $(pactl list short sinks | cut -f2 | fzf)
To make the sink permanently the default, follow this:
First, open the file /etc/pulse/default.pa using:
sudo -H gedit /etc/pulse/default.pa
Then scroll to the bottom of the file, where two lines starting with set- will be commented out.
Now, uncomment these lines and replace the words input and output with the number of the sink (for output) / source (for input) that you want to be the default.
Example (sets both default input and output):
### Make some devices default
set-default-sink 3
set-default-source 3
PS: As discussed in the comments with Bim, it is also possible (according to him) to put the input/output name in /etc/pulse/default.pa instead of the input/output number.
Example:
### Make some devices default
set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo
set-default-source alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
After doing this, save and exit. Then, delete the ~/.config/pulse directory by running rm -r ~/.config/pulse, and then reboot the system. Once the system reboots, the appropriate devices should now be set as the defaults.
EDIT:
As mentioned by ahmorris in his answer, some had to comment this line load-module module-switch-on-connect in the file /etc/pulse/default.pa to be # load-module module-switch-on-connect in order to make the changes persistent.
To make Singrium's answer work, I had to comment out this line from my /etc/pulse/default.pa by adding the #:
# load-module module-switch-on-connect
Otherwise, on startup my audio device would be set to my default device, but then would switch to my USB hub once it was detected. This prevents that switch and ensures your chosen audio device is the output.
This can be done with PulseAudio Volume Control if you prefer to use a GUI.
Once you've opened PulseAudio Volume Control, choose the configuration (the last tab), then select the output and/or input you want to use from the profile dropdown menu.
It should look similar to this
PulseAudio Volume Control can also be used to adjust volume levels for each input, output, system sounds and applications that are currently in use.
Here's a post from Linuxhint with more info on PulseAudio.
(1) I have some error en my /var/log/syslog in all case with number or all text:
[pulseaudio] main.c: Sink output 2 does not exist.
[pulseaudio] main.c: Sink output 'alsa_output.pci-0000_00_1f.3.analog-stereo' does not exist.
Ubuntu already stores the last selected audio device across reboots. Just things like USB docking stations or HDMI devices might mess up this mechanism, because they are detected as last device during boot and Ubuntu thinks, they just got connected.
So the most simple solution would be in many cases, only to comment the automatic switching on connect (load-module module-switch-on-connect) as outlined in this answer: https://askubuntu.com/a/1115641/39966
All the set-default-sink / -source commands or configurations may be not needed in most of the cases.
At the end of the day this was / is a bug in Ubuntu, which is at least for HDMI devices considered to be solved in recent versions.
There is still another open bug for USB devices.
You can ignore the bit about having to change via command line, the bit that fixed the audio devices resetting was editing the /etc/pulse/default.pa file. Change line load-module module-stream-restore to load-module module-stream-restore restore_device=false and then restart pulse audio with pulseaudio -k.
You should now be able to update the audio sink and source via settings > sound and they should persist past a log out/in and system restart.
I had my rear panel and webcam mics. The issue was that every time I turned my PC on, the webcam mic was the default, instead of the desired rear panel mic. So I went ahead and installed pavucontrol and at the Configuration tab I simply turned it off, for god's sake:
Simple fix in 19.10 that worked for me:
I couldn't get the solution @singrium proposed to persist on Ubuntu 19.10. It worked with device numbers in
/etc/pulse/default.pa
but as I connected for example my headset device numbers were changing and things stopped working. It didn't work with device names in/etc/pulse/default.pa
.The simple workaround I found is adding the
pactl set default sink
command in startup applications.pactl list short sinks
pactl set-default-sink <Your_Device_Name>
This should work without giving you an error message.
pactl set-default-sink 'Your-Device-Name'
You are now good to go. Your default audio device will be set on each boot and as such be persistent. If you want to change the default device simply edit the device name in startup applications command.
EDIT (05/03/2020):
It seems that @phanky5 figured out a simpler solution. Please check it before you try this one.
Here is a well explained tutorial to set a default audio input/output.
First: List the audio output devices using
Example output:
Second: To set a default output device, run the command
Example:
pactl set-default-sink 'alsa_output.pci-0000_00_1f.3.analog-stereo'
If you switch sinks a lot, you can use fzf to select one via the command line and make it the default:
To make the sink permanently the default, follow this:
First, open the file /etc/pulse/default.pa using:
Then scroll to the bottom of the file, where two lines starting with
set-
will be commented out.Now, uncomment these lines and replace the words input and output with the number of the sink (for output) / source (for input) that you want to be the default.
Example (sets both default input and output):
PS: As discussed in the comments with Bim, it is also possible (according to him) to put the input/output name in
/etc/pulse/default.pa
instead of the input/output number.Example:
After doing this, save and exit. Then, delete the ~/.config/pulse directory by running
rm -r ~/.config/pulse
, and then reboot the system. Once the system reboots, the appropriate devices should now be set as the defaults.EDIT:
As mentioned by ahmorris in his answer, some had to comment this line
load-module module-switch-on-connect
in the file/etc/pulse/default.pa
to be# load-module module-switch-on-connect
in order to make the changes persistent.To make Singrium's answer work, I had to comment out this line from my
/etc/pulse/default.pa
by adding the#
:Otherwise, on startup my audio device would be set to my default device, but then would switch to my USB hub once it was detected. This prevents that switch and ensures your chosen audio device is the output.
This can be done with
PulseAudio Volume Control
if you prefer to use a GUI.Once you've opened PulseAudio Volume Control, choose the
configuration
(the last tab), then select the output and/or input you want to use from theprofile
dropdown menu. It should look similar to thisPulseAudio Volume Control
can also be used to adjust volume levels for each input, output, system sounds and applications that are currently in use.Here's a post from Linuxhint with more info on PulseAudio.
This worked for me in Ubuntu 20.04.
Like was said before you have to list the audio output devices:
And than you can add your chosen device to /etc/pulse/client.conf file like this:
NOTE: You have to remove the "!" from the original line. In Ubuntu 20.10, you have to remove the ";" from the original line.
In my case, on my Bionic/18.04.3 changes in /etc/pulse/default.pa doesn't works (1)!
works fine in CLI,
make change in my ~/.profile based on post How to startup a script automatically after login, add line:
and it works after reboot
(1) I have some error en my /var/log/syslog in all case with number or all text:
[pulseaudio] main.c: Sink output 2 does not exist.
[pulseaudio] main.c: Sink output 'alsa_output.pci-0000_00_1f.3.analog-stereo' does not exist.
Ubuntu already stores the last selected audio device across reboots. Just things like USB docking stations or HDMI devices might mess up this mechanism, because they are detected as last device during boot and Ubuntu thinks, they just got connected.
So the most simple solution would be in many cases, only to comment the automatic switching on connect (
load-module module-switch-on-connect
) as outlined in this answer: https://askubuntu.com/a/1115641/39966All the
set-default-sink
/-source
commands or configurations may be not needed in most of the cases.At the end of the day this was / is a bug in Ubuntu, which is at least for HDMI devices considered to be solved in recent versions. There is still another open bug for USB devices.
See also Selected Sound Output Device Not Persisting Between Reboots in gnome-control-center
You can achieve this just using
pulseaudio
standard configuration file to do the following:Steps
List your devices:
Copy the name of the device that you want to make the default. Names are long. Something like
alsa_output.pci-0000_00_1f.3.analog-stereo
.Now let's configure pulseaudio:
Disable the pulseaudio switching to the latest plugged device. For this, make sure the following lines are starting with a
#
:Now go to the bottom of the file and make your device the default:
Save the file and exit.
Restart pulseaudio with
pulseaudio -k
.Sometimes you need to delete the entire
~/.config/pulse
folder.This worked for me.
You can ignore the bit about having to change via command line, the bit that fixed the audio devices resetting was editing the
/etc/pulse/default.pa
file. Change lineload-module module-stream-restore
toload-module module-stream-restore restore_device=false
and then restart pulse audio withpulseaudio -k
.You should now be able to update the audio sink and source via settings > sound and they should persist past a log out/in and system restart.
I had my rear panel and webcam mics. The issue was that every time I turned my PC on, the webcam mic was the default, instead of the desired rear panel mic. So I went ahead and installed
pavucontrol
and at the Configuration tab I simply turned it off, for god's sake:Then run: