You are not logged in.

#1 2023-03-11 18:07:26

Registered: 2023-02-24
Posts: 1

Stuck writing a script to toggle the default sink with WirePlumber

As per the pipewire wiki page says, first I determine the node number of the 2 concerned sinks using wpctl status:

 ├─ Devices:
 │      48. Navi 10 HDMI Audio                  [alsa]
 │      62. JDS Labs Atom DAC+                  [alsa]
 │      64. Starship/Matisse HD Audio Controller [alsa]
 ├─ Sinks:
 │  *   32. JDS Labs Atom DAC+ Analog Stereo    [vol: 1.00]
 │      46. Starship/Matisse HD Audio Controller Digital Stereo (IEC958) [vol: 1.00]
 │      70. Navi 10 HDMI Audio Digital Stereo (HDMI 4) [vol: 0.40]

I determined that node 32 and node 46 are 2 sinks that I want to switch on-the-fly
After that, this script is what i have so far:

# Script to switch between speaker and headphones using wireplumber
# assumed IDs are 32 (for headphones) and 46 (for speakers)


if [ ! -e $TOGGLE ]; then
	touch $TOGGLE
	wpctl set-default 32
	wpctl set-default 46

Now normally this would work as I tested it multiple times, but after a reboot, the nodes numbers randomized and mess up my script. Is there a way to set a default sink in WirePlumber using something more permanent across system reboots? I have an idea to write 2 Lua scripts that sets the nodes priority, but i am not sure how to make WirePlumber loads the correct one on-the-fly as I understand it, policies and configs are loaded at startup time.


Board footer

Powered by FluxBB