From e203311de813949dec992b76b04410068768eaf5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 10 Mar 2021 21:21:55 +0100 Subject: =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/gkleen@sif/scripts/mute.zsh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 accounts/gkleen@sif/scripts/mute.zsh (limited to 'accounts/gkleen@sif/scripts') 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 @@ +#!/usr/bin/env zsh + +lockFile=~/.mute.flock + +case $1 in + mute) + ( + flock -n 9 || exit 1 + sleep 0.2 + pacmd set-source-mute @DEFAULT_SOURCE@ 1 + ) 9<>${lockFile} & + ;; + unmute) + set -o pipefail + while fuser ${lockFile} 2>/dev/null | cut -d ':' -f 2- | xargs -r -- kill; do sleep 0.001; done + pacmd set-source-mute @DEFAULT_SOURCE@ 0 + ;; +esac -- cgit v1.2.3