summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/scripts/mute.zsh
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2021-03-10 21:21:55 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2021-03-10 21:21:55 +0100
commite203311de813949dec992b76b04410068768eaf5 (patch)
tree7ab620c96fbb8316b16c7f48546bc7e772bff939 /accounts/gkleen@sif/scripts/mute.zsh
parent75dfe61a72f41c55b281bc81aa2e8b6e708a6124 (diff)
downloadnixos-e203311de813949dec992b76b04410068768eaf5.tar
nixos-e203311de813949dec992b76b04410068768eaf5.tar.gz
nixos-e203311de813949dec992b76b04410068768eaf5.tar.bz2
nixos-e203311de813949dec992b76b04410068768eaf5.tar.xz
nixos-e203311de813949dec992b76b04410068768eaf5.zip
Diffstat (limited to 'accounts/gkleen@sif/scripts/mute.zsh')
-rwxr-xr-xaccounts/gkleen@sif/scripts/mute.zsh18
1 files changed, 18 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/scripts/mute.zsh b/accounts/gkleen@sif/scripts/mute.zsh
new file mode 100755
index 00000000..1b30ad67
--- /dev/null
+++ b/accounts/gkleen@sif/scripts/mute.zsh
@@ -0,0 +1,18 @@
1#!/usr/bin/env zsh
2
3lockFile=~/.mute.flock
4
5case $1 in
6 mute)
7 (
8 flock -n 9 || exit 1
9 sleep 0.2
10 pacmd set-source-mute @DEFAULT_SOURCE@ 1
11 ) 9<>${lockFile} &
12 ;;
13 unmute)
14 set -o pipefail
15 while fuser ${lockFile} 2>/dev/null | cut -d ':' -f 2- | xargs -r -- kill; do sleep 0.001; done
16 pacmd set-source-mute @DEFAULT_SOURCE@ 0
17 ;;
18esac