38

How do I set the default profile that is used after each boot, in PulseAudio?

When I boot, sound doesn't work. If I open the PulseAudio Volume Control app, and go to the Configuration pane and select "Analog Surround 4.0 Output" from the Profile drop-down menu, then sound works again. However this only lasts until the next reboot.

How do I configure the system to use that profile in the future after reboots?

D.W.
  • 4,070

3 Answers3

53

Add the following to /etc/pulse/default.pa:

set-card-profile <cardindex> <profilename>

How do we figure out what to use as cardindex and as profilename? Here's one way. Configure the card so everything is working. The cardindex will usually be 0, but you can find it by running pacmd list-cards and looking at the line index: .... To find the profilename, use

pacmd list-cards | grep 'active profile'

The name of the current profile should appear in the output. Remove the angle brackets (the < and >).

You can test your configuration by running

pactl set-card-profile <cardindex> <profilename>

from the command line to see if it sets the profile correctly, then add it to /etc/pulse/default.pa.

Since the index name is dynamic (it can change your PCI device index if you boot with a USB audio device plugged in), you could use <symbolic-name> instead of <index> (if you run pacmd list-cards, the symbolic name is right below the index). Also, the command might fail if the device is missing when starting pulseaudio so it might worth to wrap the command with an .ifexists clause:

.ifexists <symbolic-name>
pactl set-card-profile <symbolic-name> <profilename>
.endif
D.W.
  • 4,070
  • 2
    If you have multiple audio devices whose ordering is not fixed, you can also use udev rules to configure a Pulseaudio profile for a device. This allows identifying the device by vendor/product IDs, serial number, or by other means. The rule element for setting the Pulseaudio profile is ENV{PULSE_PROFILE_SET}="<profilename>" – telcoM Aug 15 '18 at 06:37
  • 1
    suggested an edit: index is dynamic, and in my case changes if I boot with the USB audio plugged in. – maxadamo Jun 25 '19 at 09:01
  • 3
    This however does not work when a device is hotplugged (i.e.: a bluetooth headset for instance). Running pactl... works, but setting the same command into /etc/pulse/default.pa does not have any effect... I'm trying to set headset_head_unit profile by default instead of a2dp_sink for my headset unit. – Mauro Molinari Feb 15 '21 at 08:43
  • One might also want to check /etc/pulse/daemon.conf file to see if /etc/pulse/default.pa is used as default config and uncomment it if it's not and then reload pulseaudio with pulseaudio -k. – Eduard Sukharev May 26 '21 at 16:21
  • It's so complicated, man, what's the difference between: pactl set-card-profile and pacmd set-default-sink – Pavel Tankov Oct 12 '22 at 15:15
  • @PavelTankov, please don't use the comment section here to ask questions. Instead, use the 'Ask Question' button in the upper-right, and make sure to provide full context for your question. – D.W. Oct 12 '22 at 16:54
  • Thanks, your solution helped me and worked to set the card profile correctly on pulseaudio -k, but in Ubuntu 22.04 other things than Pulseaudio initialization keeps altering the card profile setting, and I had to do a couple of other things to set it right and make it stay right. The information about that is in this answer: https://askubuntu.com/a/1450325/339875 – njlarsson Jan 15 '23 at 20:31
1

Ended up writing this to help change the profiles. Only worried about bluetooth but you can edit it to your needs to select other sources in pactl list cards.

index=$(pactl list cards | grep -B1 "bluez_card" | grep -oP '(?<=Card #)\d+')

pactl set-card-profile $index a2dp-sink

pactl set-card-profile $index off

pactl set-card-profile $index headset-head-unit

robcxyz
  • 111
  • 2
0

Inserting the command line in /etc/pulse/default.pa doesn't work for me; it caused an error.

I've just worked around putting a command

pactl set-card-profile <symbolic-name> <profilename>

in the autostart task of linux, and it works.

AdminBee
  • 22,803