diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-12-14 09:45:26 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-12-14 09:52:33 +0000 |
commit | e1d0877d56180dc1b36a53b10ce4c516190b8c7e (patch) | |
tree | 00e72736ad16d9f8aa4ee30c3174630d3536ffbb | |
parent | 7061f0dd46975836e79df9df8ad8b183f10920ef (diff) | |
download | dotfiles-e1d0877d56180dc1b36a53b10ce4c516190b8c7e.tar.gz |
add pactl-tunnel-sink
-rwxr-xr-x | bin/pactl-tunnel-sink | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/pactl-tunnel-sink b/bin/pactl-tunnel-sink new file mode 100755 index 00000000..5ad8df25 --- /dev/null +++ b/bin/pactl-tunnel-sink @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +set -e +. ~/src/dotfiles/lib-src/posix-defuns.sh + +[ \( "$1" = --client -o "$1" = --server \) -a "$#" -eq 2 ] \ + || fail "usage: pactl-tunnel-sink --client|--server ADDRESS" + +addr=$2 +port=4656 +def= mod= + +cleanup() { + set +e + [ -n "$def" ] && pactl set-default-sink "$def" + [ -n "$mod" ] && pactl unload-module "$mod" +} +trap cleanup INT TERM EXIT + +case "$1" in + --client) + def="$(pactl get-default-sink)" + mod="$(pactl load-module module-tunnel-sink server=tcp:$addr:$port)" + pactl set-default-sink "tunnel-sink.tcp:$addr:$port" + ;; + + --server) + sudo firewall-cmd --add-port=$port/tcp + mod="$(pactl load-module module-native-protocol-tcp port=$port listen=$addr)" + ;; +esac + +read -n 1 -r -s -p "Press any key to exit .." |