41 lines
1.1 KiB
Bash
Executable File
41 lines
1.1 KiB
Bash
Executable File
# wait until pw-link port becomes available
|
|
# $1: port identifier
|
|
wait_for_port() {
|
|
for _ in $(seq 1 10); do
|
|
if pw-link -io 2>/dev/null | grep -Fq "$1"; then
|
|
return 0
|
|
fi
|
|
sleep 1
|
|
done
|
|
echo "Timed out waiting for PipeWire port: $1" >&2
|
|
return 1
|
|
}
|
|
|
|
# link two pipewire ports together. waits for htme to exist first.
|
|
# $1: output port
|
|
# $2: input port
|
|
link_ports() {
|
|
wait_for_port "$1"
|
|
wait_for_port "$2"
|
|
|
|
# pw-link errors if a link already exists, but we don't want that to fail the script
|
|
pw-link "$1" "$2" 2>/dev/null || true
|
|
}
|
|
|
|
# link clementine -> combine
|
|
link_ports "clementine:monitor_FL" "combine:playback_FL"
|
|
link_ports "clementine:monitor_FR" "combine:playback_FR"
|
|
|
|
# link element -> combine
|
|
link_ports "element:monitor_FL" "combine:playback_FL"
|
|
link_ports "element:monitor_FR" "combine:playback_FR"
|
|
|
|
# link game -> combine
|
|
link_ports "game:monitor_FL" "combine:playback_FL"
|
|
link_ports "game:monitor_FR" "combine:playback_FR"
|
|
|
|
# link combine -> usb_c_sink
|
|
link_ports "combine:monitor_FL" "$USB_C_SINK:playback_FL"
|
|
link_ports "combine:monitor_FR" "$USB_C_SINK:playback_FR"
|
|
|