How do I permanently set the default audio device in Manjaro xfce with Pipewire?

Looks like this topic is of very low interest only.
Perhaps I might rise some curiosity when I mention something very peculiar:

The IDs of the sound sources and sinks are not always the same after each reboot. From time to time, the IDs change:

├─ Sinks:
│     34. Internes Audio Analog Stereo        [vol: 0.74]
│  *  47. GM107 High Definition Audio Controller [GeForce 940MX] Digital Stereo (HDMI) [vol: 0.70]
├─ Sinks:
│      31. Internes Audio Analog Stereo        [vol: 0.74]
│  *   48. GM107 High Definition Audio Controller [GeForce 940MX] Digital Stereo (HDMI) [vol: 0.55]

Can anybody explain why this happens?
Anyway, as the sound IDs are apparently re-enumerated on each reboot, it does not seem to be enough to simply create an autostart entry with wpctl set-default {ID} but the correct ID has to be found out each time before attempting to set the default:

#!/bin/bash
# Sets the default sound device
# Set space as the delimiter
IFS=' '

# Read the split words into an array based on space delimiter
read -a strarr < <( wpctl status | grep HDMI )
# We will have to check whether our device is already the default; 
# in that case, the ID entry starts with an asterisk.
# As it is complicated in bash to check if a string contains an asterisk (because it is a wildcard character), 
# checking is only done if the first element of the array is alphanumeric or not 
# Hopefully, wireplumber's IDs will always remain two-digit numbers :)
if [[ ${strarr[1]:0:2} = *[^[:alnum:]]* ]]; then
   foundID="${strarr[2]:0:2}"
   else
   foundID="${strarr[1]:0:2}"
fi
wpctl set-default "${foundID}"                   

Not meant as a complaint - but I understand why Linux will never defeat Windows on the desktop :slight_smile:

Hi @DAC324,

Please have a look here, this might be it:

Setting up a default audio sink help - Multimedia - EndeavourOS

It might alkso not, I don’t use sound, so don’t really know. But maybe it helps!

Not really as this guy is using pulseaudio instead of pipewire and wireplumber, just like in the question I linked to in my initial post: How to set default audio devices on XFCE?

For now, my script looks like a suitable workaround, although I must admit that I am still surprised by the fact that this topic seems to be of almost no interest. Perhaps the times of Linux / Kodi based HTPCs are gone for good, and these days, everybody uses Apple TV or something similar :slight_smile:

Possible, but I highly doubt it.

But then, all those folks out there are connecting their Super-Duper 7.1 Dolby Surround Home Cinema Receivers using those wobbly 3.5" phone jacks to their Realtek Onboard sound? Looks like this is the case but it’s hard to believe :frowning:

still use htpc with libreelec every day, so not dead here

But i only have 1 audio device so i can’t help you

1 Like
  1. Not everyone has a problem; and
  2. not all problems make it to the internet.

But you are using your Onboard sound, don’t you? In that case, there’s no problem because wireplumber seems to always default to an Onboard sound chip if it finds one.

Jep that is true, that’s why i said i can’t help you with your problem

Indeed. But as said, I had assumed that this would have been of interest to more than three people :slight_smile:
In particular, with HTPCs where TV and audio devices are supposed to be connected via HDMI, and graphics cards being able to output audio via HDMI as well, I guess it will be extemely annoying if you would have to manually switch your audio output from Onboard to HDMI each time you start the HTPC.

Perhaps…maybe…

Thought just crossed my mind. Couldn’t you disable the wrong card in the BIOS/UEFI? That way, there’s only one to use.

(I’m assuming that’s the wrong one, else why have something different?)

Indeed, that is, at a first glance, worth thinking about. In the HTPC scenario I mentioned above, this sounds like the best solution.

Unfortunately, my graphics card does not provide a microphone input. That’s why I have to leave the onboard sound chip still enabled.

In that vase, I have to

:man_shrugging:

again.

Sorry.

pacmd only works on PulseAudio

But pactl works on both PulseAudio and PipeWire

To show all available sinks

pactl list sinks short

To show default sink

 pactl get-default-sink

To change default sink to another sink NAME

pactl set-default-sink NAME

The sink number can also be used in PulseAudio but the sink order and numbering is mutable
Internal devices do not change pci location code, but a USB device would change name if plugged in to a different USB socket

That’s encouraging.

Just encountered another weirdness: As soon as the system switches off the monitors because of inactivity, to save power, the default sink is reset to be the onboard sound chip.
Unfortunately, xfce does not offer the possibility for programs to be started when the mouse is moved, and the system switches the monitors back on.

If default sink setting is not being respected disable the unused onboard sink

Go to PulseAudio Volume Control > Configurationpavucontrol -t 5

Change the Profile for onboard audio from Analog Stereo Duplex to Analaog Stereo Input
and click the padlock icon to lock the profile

Thank you very much for that good advice.
However, when I start pavucontrol -t 5, I get the configuration dialog, but without any padlock icon:

The lock must be available for PulseAudio only

I don’t expect the Profile to change but it is a possibility. If the profile is unchanged after screen is blanked or after system reboot it should be persistent at all other times

That was the best advice for this problem. Thanks a lot once again. Looks like that configuration change now even survived hibernation mode.
I must admit that I wasn’t aware of the possibility to switch devices to input only.

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