diff options
| author | Josh Rahm <joshuarahm@gmail.com> | 2022-01-10 14:07:32 -0700 |
|---|---|---|
| committer | Josh Rahm <joshuarahm@gmail.com> | 2022-01-10 14:07:32 -0700 |
| commit | 8ff5dec689c3f4577960c25e284add5a5e9a9fcf (patch) | |
| tree | 080b5ed1c737ad8bce666b74ea7fb6c9b80a8272 /extras | |
| parent | 16c92a6f4b2072db37022b7176ad44d108dfa42a (diff) | |
| download | rde-8ff5dec689c3f4577960c25e284add5a5e9a9fcf.tar.gz rde-8ff5dec689c3f4577960c25e284add5a5e9a9fcf.tar.bz2 rde-8ff5dec689c3f4577960c25e284add5a5e9a9fcf.zip | |
Change set-sink.sh
Before this script would use the PID of the current window to infer the
input to switch. However some frontends use a daemon to output the
sound, so it doesn't work in that case.
Instead, now, set-sink will prompt the user to select the active sink to
switch. If there is only one active sink it will automatically move
that one.
Diffstat (limited to 'extras')
| -rwxr-xr-x | extras/HOME/.local/bin/set-sink.sh | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/extras/HOME/.local/bin/set-sink.sh b/extras/HOME/.local/bin/set-sink.sh index be04833..aa0b91c 100755 --- a/extras/HOME/.local/bin/set-sink.sh +++ b/extras/HOME/.local/bin/set-sink.sh @@ -1,7 +1,6 @@ #!/bin/bash -current_pid=$(xdotool getactivewindow getwindowpid) -DMENU=(dmenu -i -nf "#88ff88" -sb "#88ff88" -p "Move Audio" -l 12 -dim 0.4) +DMENU=(dmenu -i -nf "#88ff88" -sb "#88ff88" -p "Move Audio To" -l 12 -dim 0.4) sinks="$( pactl list sinks | while read line ; do @@ -19,27 +18,34 @@ sinks="$( client_input="$( pactl list sink-inputs | while read line ; do case "$line" in - application.process.id\ =*) + application.name\ =*) app="${line//*= \"}" app="${app%%\"}" + echo "$app: $media "'#'"$obj" ;; - object.id\ =*) - obj="${line//*= \"}" - obj="${obj%%\"}" - echo "$obj $app" + media.name\ =*) + media="${line//*= \"}" + media="${media%%\"}" + ;; + Sink\ Input\ \#*) + obj="${line//*#}" ;; esac done )" -input_sink=$(echo "$client_input" | grep "$current_pid\$") -input_sink=${input_sink%% *} +echo "Client Input: $client_input" + +if [[ "$(wc -l <<< "$client_input")" -gt 1 ]] ; then + client_input="$("${DMENU[@]}" -p "Move Audio From" <<< "$client_input")" +fi + +input_sink=${client_input//*#} -selected_sink=$(echo "$sinks" | "${DMENU[@]}") +selected_sink=$("${DMENU[@]}" <<< "$sinks") sink_num=${selected_sink//*#} -#echo "$sinks" -#echo "$client_input" +echo "Sinks: $sinks" echo "pactl move-sink-input $input_sink $sink_num" pactl move-sink-input "$input_sink" "$sink_num" |