diff options
author | jao <jao@gnu.org> | 2019-10-12 15:33:10 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2019-10-12 15:33:24 +0100 |
commit | 6173b1cab8a5df50de7d72eb42f3ababae782e49 (patch) | |
tree | c707de57adef8cc24dec3dd1b6b2c04dc7d92af0 /bin | |
parent | 55981bd182a38ddff96bed317dafb8e54cb697e5 (diff) | |
download | xmobar-config-6173b1cab8a5df50de7d72eb42f3ababae782e49.tar.gz xmobar-config-6173b1cab8a5df50de7d72eb42f3ababae782e49.tar.bz2 |
toggleMonitor
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/toggle-pipe.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/toggle-pipe.sh b/bin/toggle-pipe.sh new file mode 100755 index 0000000..2dfc8b9 --- /dev/null +++ b/bin/toggle-pipe.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +[[ -z $1 ]] && echo "Usage: toggle-pipe.sh path-to-pipe" && exit 1 + +state="$1.state" + +[[ -p $1 ]] || mkfifo $1 + +[[ -f $state ]] || echo 0 > $state + +v=$(<$state) + +if [[ x$v == x1 ]]; then v=0; else v=1; fi + +echo $v > $state; +echo -e "$v\\\n" > $1; |