aboutsummaryrefslogtreecommitdiff
path: root/extras/HOME
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-01-10 11:44:08 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commit6c9b9c8ef89f250ce03ffdb6baa0a8ffa966beac (patch)
tree5afac5731685741116a4eb2da352d79dbcea6f8f /extras/HOME
parent4acf25fc6f3b2ad5c1a18600efb11ff65115990e (diff)
downloadrde-6c9b9c8ef89f250ce03ffdb6baa0a8ffa966beac.tar.gz
rde-6c9b9c8ef89f250ce03ffdb6baa0a8ffa966beac.tar.bz2
rde-6c9b9c8ef89f250ce03ffdb6baa0a8ffa966beac.zip
Add script to set the PulseAudio sink for the current window.
This binding is set to <C-z>a. It creates a dmenu prompting the user to select which output device the current application should send audio to. In the future I might create an analog for input devices, but as things stand, I change input so much more infrequently that pavucontrol is probably fine for that.
Diffstat (limited to 'extras/HOME')
-rwxr-xr-xextras/HOME/.local/bin/set-sink.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/extras/HOME/.local/bin/set-sink.sh b/extras/HOME/.local/bin/set-sink.sh
new file mode 100755
index 0000000..be04833
--- /dev/null
+++ b/extras/HOME/.local/bin/set-sink.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+current_pid=$(xdotool getactivewindow getwindowpid)
+DMENU=(dmenu -i -nf "#88ff88" -sb "#88ff88" -p "Move Audio" -l 12 -dim 0.4)
+
+sinks="$(
+ pactl list sinks | while read line ; do
+ case "$line" in
+ Sink\ \#*)
+ name="${line//*#}" ;;
+ Description:\ *)
+ description="${line//*: }"
+ echo "$description "'#'"$name"
+ ;;
+ *) ;;
+ esac
+ done)"
+
+client_input="$(
+ pactl list sink-inputs | while read line ; do
+ case "$line" in
+ application.process.id\ =*)
+ app="${line//*= \"}"
+ app="${app%%\"}"
+ ;;
+ object.id\ =*)
+ obj="${line//*= \"}"
+ obj="${obj%%\"}"
+ echo "$obj $app"
+ ;;
+ esac
+ done
+)"
+
+input_sink=$(echo "$client_input" | grep "$current_pid\$")
+input_sink=${input_sink%% *}
+
+selected_sink=$(echo "$sinks" | "${DMENU[@]}")
+sink_num=${selected_sink//*#}
+
+#echo "$sinks"
+#echo "$client_input"
+
+echo "pactl move-sink-input $input_sink $sink_num"
+pactl move-sink-input "$input_sink" "$sink_num"