Setting up a default audio sink help

Hi all, I’m struggling to change my default audio sink (sound output device). I have two devices shown in the gui sound device manager - the motherboard’s built in audio out and the hdmi out to my monitor that I actually use.

On boot, the system auto selects the motherboard sound out, which is not normally connected to anything. It’s a bit of an inconvenience to manually change it each time so I want to auto set it. I’m on the xfce desktop, with the default pipewire config installed from the offline installer. Following this post on redit, I created an /etc/pipewire directory. I then copied /usr/share/pipewire/pipewire.conf into this directory and added default.configured.audio.sink = { "name": "your_device_name" } in the context.properties part (with “your_device_name” substituted for the name of the hdmi interface name learned from pactl list short sinks.

The key bit of the file looked like this:

context.properties = {
    ## Configure properties in the system.
    #library.name.system                   = support/libspa-support
   #default.configured.audio.sink = { "name": "the name I pulled from pactl" }

I then rebooted the system, but the motherboard sound out was still selected as default. I instead tried moving the pipewire-pulse.conf to the /etc/pipewire directory and adding the same default.configured… line to that. That did seem to switch the default audio interface (I have the system set to automatically play a test sound on login) but broke the gui sound control.

I feel like I must be close to the right answer here, but I’m now officially lost. Can anyone point me to what I did wrong?

What Desktop Environment are you using (e.g. KDE, Xfce, Gnome etc)?

Xfce, default from the offline installer - iirc KDE plasma set a persistent default in their GUI.

I’ve not used pipewire with Xfce, sorry. (Yes, Plasma does set a persistent default).

1 Like

So, I have an interim kludge solution - I have created a start up process using pactl. This is set to run the following command on login;

pactl get-default sink | pactl set-default-sink alsa_output.pci-0000_03_00.1.hdmi-stereo-extra3

Where the “alsa_output...” part is the name of the device I want as my default sink. As I’m using pipewire-pulse, afaik pactl is still a sensible tool to use on xfce.

While this does work, I can’t help but think there must be a way to properly set the config files I was messing with earlier which would choose the default without having to create a start up process.

I’m not familiar with XFCE so someone else may have a better answer. But you could try using pavucontrol or pasystray maybe?

OK, so I solved it. The problem with my approach above, which sort of half worked is that the command seems to run before the audio server is fully initialised. The solution was to create a bash script (my first one!) with a delay at the start, so the audio switching pactl command starts only after the audio server is fully initialised. This script runs on startup.

#!/bin/bash
sleep 3;
pactl get-default-sink;
pactl set-default-sink alsa_output.pci-0000_03_00.1.hdmi-stereo-extra3;
play /home/tom/Downloads/sounds_Chicago95_stereo_desktop-login.wav 

For other newbies only! This guide was helpful to me for to learn to write the script. However, if you just follow this, your script will not be able to run persistently. You need to add the directory where you keep your script to /etc/profile, with a line like append_path '/home/[your username]/scripts' with the other append_path lines.

And, yes, I did all this so the windows 95 theme could play when my computer starts up. My only defense is that scientists agree it is the most soothing sound committed to digital form.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.