21

I list sources and sinks as follows:

pactl list sources
pactl list sinks

The output I get is:

...
    Ports:
        analog-input-internal-mic: Internal Microphone (priority: 8900)
        analog-input-headphone-mic: Microphone (priority: 8700)
        analog-input-headset-mic: Headset Microphone (priority: 8800)
...
    Ports:
        analog-output-speaker: Speakers (priority: 10000)
        analog-output-headphones: Headphones (priority: 9000, available)

How do I change the priorities listed above and have them fixed at what I change them to? Note that I am not looking to set a default source and sink or to delete unwanted sources or sinks, I just want to be able to assign them different priorities.

mcarans
  • 1,175

2 Answers2

13

First, use the following command to see the list of cards and ports:

pactl list sinks

Then, run (change out the filename to correspond to the port you want to modify (list the files in the paths/ folder to see which ones there are)):

sudo vim /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf

to modify the priority (that value is multiplied by 100).

Ken
  • 146
  • 3
    If you're using PipeWire the PulseAudio configuration files are stored in: /usr/share/alsa-card-profile/mixer/paths/ – adamnejm Mar 16 '21 at 14:45
  • 1
    System specific configs can be found in /etc/pulse/ and probably those should be modified to override values in /usr/share/ that will be stepped on during upgrades. – user10489 Jul 07 '21 at 18:24
  • 3
    OK, but if this priority even lowest-first or highest-first? Ungooglable. – alamar Oct 23 '21 at 12:13
  • 1
    @alamar Priority is highest first. This can be verified by the output of the command pactl list sinks. The priority of your choice should be higher than the other ports. If needed you need to reduce the priority of the other ports by editing other files in the same directory. However, modifying /etc/pulse/default.pa is preferred to preserve the settings across upgrades. – amit kumar Jan 07 '22 at 08:02
  • @user10489 A good answer for modifying /etc/pulse/default.pa (preferred to preserve the settings across upgrades) is at https://unix.stackexchange.com/a/182294/11169 – amit kumar Jan 07 '22 at 08:03
  • @amitkumar the default port or sink might change if you use r.g. bluetooth for a while, please see this issue. How can you prevent that? – jarno Mar 10 '22 at 21:57
  • Sinks also have priorities, but the files are for ports. Can you set priorities for sinks, too? – jarno Mar 10 '22 at 22:08
1

I had to enable some obscure setting in the UI (?) in order to actually automatically switch between ports, HDMI vs. internal audio in my case. Without the setting, it won't switch the ports regardless of their priorities.

Perhaps it is module-switch-on-connect

I think the following answer is relevant: https://askubuntu.com/a/158250/480388

alamar
  • 113
  • I wonder if it was module-udev-detect – alamar Jan 08 '22 at 09:17
  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. – Error404 Jan 08 '22 at 09:55
  • Can you be a bit more specific about the setting you enabled? – BeastOfCaerbannog Jan 08 '22 at 10:51
  • Unfortunately, I didn't find it yet, I will try to re-discover it. – alamar Jan 08 '22 at 14:11
  • I commented out load-module module-switch-on-connect and load-module module-switch-on-port-available in /etc/pulse/default.pa, Then ran pulseaudio -k and auto-switching to undesired sink on new audio device connect stopped . – d9k Feb 27 '23 at 05:02