From ba1dea3668c6ceb2f6712473cccf3640a168f320 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Thu, 6 Apr 2017 22:26:26 -0700 Subject: [PATCH] [Linux] Support muting and unmuting exactly one source --- dotfiles/lib/bin/mute_current_window.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dotfiles/lib/bin/mute_current_window.sh b/dotfiles/lib/bin/mute_current_window.sh index 46fb96da..dbd2c224 100755 --- a/dotfiles/lib/bin/mute_current_window.sh +++ b/dotfiles/lib/bin/mute_current_window.sh @@ -1,5 +1,9 @@ #!/usr/bin/env zsh +otherinputs () { + get_sink_input_info.hs | jq 'select(.application_process_id != "'"$1"'")' +} + thePID="$(xprop _NET_WM_PID -id $(xdotool getactivewindow) | grep -Eo '[0-9]*')" sinkInfo="$(pashowinputbypid $thePID)" sinkID="$(echo $sinkInfo | jq -r .sink_input_id)" @@ -12,4 +16,9 @@ fi echo "$sinkID" -pactl set-sink-input-mute "$sinkID" "$newState" +if [[ $1 == *"only"* ]]; then + pactl set-sink-input-mute "$sinkID" 0 + otherinputs "$thePID" | jq -r .sink_input_id | xargs -I theid sh -c 'pactl set-sink-input-mute theid 1' +else + pactl set-sink-input-mute "$sinkID" "$newState" +fi