How do I teach Pipewire to pick the right output?

Pipewire isn’t as random as PulseAudio was, but it still doesn’t necessarily do the right thing when I’m plugging and unplugging devices from my laptop.

What I want to tell my system is:

  • If my BT headphones are attached, use them
  • If no BT headphones, use the HDMI output through my docking station
  • If no HDMI, use the laptop speakers
  • never use the digital or analog outputs on my docking station

This seems like something that ought to be easy to do with priority/weighing, right? So, if the heaviest gets selected:

  • BT Headphones = 100
  • HDMI = 50
  • built-in = 10
  • usb digital = -1
  • usb analog = -1

but, I don’t see a way to do that in pipewire. I’ve seen a couple things that suggest changing ALSA priority in /usr/share/alsa-card-profile/mixer/paths, but those files come from the OS, and may get stomped on in an upgrade. Is this something I can do?

For HDMI and internal speaker, you could use wpctl to make HDMI as default if available.

Run wpctl status and find part:

Audio
...
 │  
 ├─ Sinks:
 │      45. Built-in Audio Digital Stereo (HDMI) [vol: 0.74]
 │  *   46. Built-in Audio Analog Stereo        [vol: 0.54]
...

As you can see above the * sign is on Built in speaker (default). From above example we could change it to HDMI with wpctl set-default 45 where 45 is ID number of HDMI sink (see above).

Bellow are the result:

Audio
...
 ├─ Sinks:
 │  *   45. Built-in Audio Digital Stereo (HDMI) [vol: 0.74]
 │      46. Built-in Audio Analog Stereo        [vol: 0.54]

For Headphone (cable or bluetooth) as top priority, it should be already the default from ALSA configuration.

This unfortunately doesn’t work. If I set the default device using wp set-default <id>, and then I connect my headphones, set the audio device to my headphones, and then disconnect my headphones, the output device does not revert to the default that I had set, it keeps reverting to the digital audio device in my laptop dock.

https://discussion.fedoraproject.org/t/pipewire-configure-audio-channels/24237/7?u=grumpey

1 Like