How can I set the default audio device?

I’m only posting this in the perspective of non-deck version of Bazzite (i.e. no game/deck mode). I have a problem that Bazzite switches the default audio device to the onboard sound card when I starts a sunshine stream. I found that the order of audio device is determined by wireplumber. I have successfully set my desktop to use my HDMI monitor (actually connected via DisplayPort) as the default audio device without disabling the onboard sound card.

First, open a terminal, run wpctl status and note the ID next to each sink under Audio

k7so@bazzite:~$ wpctl status
...
Audio
 ├─ Devices:
 │      50. Renoir Radeon High Definition Audio Controller [alsa]
 │      51. Family 17h/19h HD Audio Controller  [alsa]
 │  
 ├─ Sinks:
 │      53. Family 17h/19h HD Audio Controller Digital Stereo (IEC958) [vol: 1.00]
 │  *   62. Renoir Radeon High Definition Audio Controller Digital Stereo (HDMI 2) [vol: 0.64]
 │  
 ├─ Sources:
 │      54. Family 17h/19h HD Audio Controller Analog Stereo [vol: 1.00]
 │  
 ├─ Filters:
 │  
 └─ Streams:
...

Note that the ID for “Family 17h…” (my onboard sound card) is 53 and that for HDMI is 62.

Then, run wpctl inspect <id>, where <id> is the ID I mentioned above. Note the value for priority.driver and priority.session.

k7so@bazzite:~$ wpctl inspect 53
id 53, type PipeWire:Interface:Node
...
  * node.description = "Family 17h/19h HD Audio Controller Digital Stereo (IEC958)"
    node.driver = "true"
  * node.name = "alsa_output.pci-0000_06_00.6.iec958-stereo"
...
  * priority.driver = "736"
  * priority.session = "736"
k7so@bazzite:~$ wpctl inspect 62
id 62, type PipeWire:Interface:Node
...
  * node.description = "Renoir Radeon High Definition Audio Controller Digital Stereo (HDMI 2)"
    node.driver = "true"
  * node.name = "alsa_output.pci-0000_06_00.1.hdmi-stereo-extra1"
...
  * priority.driver = "632"
  * priority.session = "632"

You can see that the priority for the onboard card is 736, while that for the HDMI is 632. As the onboard sound card has higher priority it will be preferred.

To fix this, we can add a config file to override the priority value for the onboard card.

Open Kate (the text editor), open a new file and paste the following contents:

monitor.alsa.rules = [
  {
    matches = [
      {
        node.name = "alsa_output.pci-0000_06_00.6.iec958-stereo"
      }
    ]
    actions = {
      update-props = {
         priority.driver = 500
         priority.session = 500
      }
    }
  }
]

In the config the part after node.name should match the node.name as shown in the wpctl inspect output. I change the priority from 736 to 500 so that it will be lower than that for my HDMI.

Save this file as /home/<your username>/.config/wireplumber/wireplumber.conf.d/51-deprio-onboard.conf. In other words, we put this file into the /home/<your username>/.config/wireplumber/wireplumber.conf.d/ directory (you need to create the intermediate directories yourself). And the name for the file is 51-deprio-onboard.conf (actually only the beginning 51- and file extension .conf matter, you can name the middle part to anything as you wish).

After placing that config file, run the command systemctl --user restart wireplumber to restart the wireplumber service.

Double check the priorities using wpctl status and wpctl inspect <id> (note that the ID will change after restarting wireplumber). You can see that the priority has been changed as desired.

Adapt this to your needs. Just remember that the priority should not be set to higher than 1500.

I believe that it should work in game mode too after editing this in desktop mode, as the creator of Bazzite said “steam game mode defaults to whatever Wireplumber’s configured default is”.

Reference: ZenLinux Blog » Blog Archive » How to Configure Audio Device Priorities in Pipewire / Wireplumber (However the configuration part is outdated)

Edit: I played around the sound setting a little more and found that the “Default Configured Devices” shown in wpctl status also matters. If there is the device that matches the default configured device, then that device should be chosen as the output. If not the device with highest priority will be chosen. It can be changed by wpctl set-default <id> or just by selecting that device in KDE.

2 Likes