wireplumber broke a lot of compatibility from 0.4 to 0.5, while writing scripts for each of them is a big time investment (personally for me). And this is severely exacerbated by absence of necessary docs. At the same time I have few streaming-studio related workstations where I just need some wiring done no matter what with minimal effort. As a result I decided to write this small ugly service.
This service is supposed to be running in parallel to wireplumber (or alternative). However, it is also useable as a minimalistic replacement.
Install
go install github.com/xaionaro-go/pw-pin/cmd/pw-pind@mainConfigure:
mkdir -p ~/.config/pw-pin
cat > ~/.config/pw-pin/config.conf <<EOFroutes:
- from: # to link mpv (matched loosely) with RODECaster Duo (left channel)
node:
- property: media.name
values: [' - mpv']
op: CONTAINS
port:
- property: port.name
values: [output_FL]
to:
node:
- property: node.name
values: [alsa_output.usb-R__DE_RODECaster_Duo_IR0037235-00.pro-output-0]
port:
- property: port.name
values: [playback_AUX0]
should_be_linked: true
- from: # to link mpv (matched loosely) with RODECaster Duo (right channel)
node:
- property: media.name
values: [' - mpv']
op: CONTAINS
port:
- property: port.name
values: [output_FR]
to:
node:
- property: node.name
values: [alsa_output.usb-R__DE_RODECaster_Duo_IR0037235-00.pro-output-0]
port:
- property: port.name
values: [playback_AUX1]
should_be_linked: true
- from: # to do not unlink from volume meters (e.g. pavucontrol)
node:
- property: media.name
values: [' - mpv']
op: CONTAINS
to:
node:
- property: media.name
values: [Peak detect]
should_be_linked: null # <- means: keep as is; but since we already matched this rule, we won't get to the next one
- from: # to unlink it from everything else
node:
- property: media.name
values: [' - mpv']
op: CONTAINS
should_be_linked: falseEOF(for the information which properties exist, see pw-dump)
Run:
"$(go env GOPATH)"/bin/pw-pindAn example of output:
streaming@void:~/go/src/github.com/xaionaro-go/pw-pin$ ~/go/bin/pw-pind
INFO[0000]main.go:70 started
INFO[0005]run.go:33 link {"From":{"NodeID":206,"PortID":208},"To":{"NodeID":114,"PortID":145}} created
INFO[0005]run.go:56 link {"From":{"NodeID":206,"PortID":208},"To":{"NodeID":74,"PortID":137}} destroyed
INFO[0005]run.go:56 link {"From":{"NodeID":206,"PortID":208},"To":{"NodeID":319,"PortID":203}} destroyedIf you need more info about property-ies mentioned in the config, try running (see props):
pw-dump --monitorAs an ugly but simple solution to make pw-pind run together with pipewire, run (under your normal user account):
mkdir -p ~/.local/bin
cat > ~/.local/bin/run-pw-pin.sh <<EOF
#!/bin/bash
killall -9 pw-pind
~/go/bin/pw-pind "\$@" &
EOF
chmod +x ~/.local/bin/run-pw-pin.shthen:
systemctl edit --user pipewireand add there:
[Service]
ExecStartPost=~/.local/bin/run-pw-pin.shThis is abuse of ExecStartPost, you generally should not do that. But it is very simple, and it works. A better solution would be to write another service file and build a guarantee one is always executed on any pipewire restart.