summaryrefslogtreecommitdiff
path: root/.config/eww/scripts/toggle
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-23 06:47:03 +0300
committerThomas Voss <mail@thomasvoss.com> 2023-08-23 06:47:03 +0300
commit7ff798534a6fb9c99611d18ee22757346798ef61 (patch)
tree1f6603ff9f3eede365e6963b3ac66b5edbd232fb /.config/eww/scripts/toggle
parent8f7cbf4ad87d63fe82173645ecb590ebb0f12354 (diff)
eww: Add an eww configuration
Diffstat (limited to '.config/eww/scripts/toggle')
-rwxr-xr-x.config/eww/scripts/toggle17
1 files changed, 17 insertions, 0 deletions
diff --git a/.config/eww/scripts/toggle b/.config/eww/scripts/toggle
new file mode 100755
index 0000000..8ce7bcc
--- /dev/null
+++ b/.config/eww/scripts/toggle
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+# Open a file descriptor for writing to create the lock if it doesn’t exist. We
+# need a lock because of race-conditions that could occur if you spam a toggle
+# over and over.
+exec 3>"${XDG_RUNTIME_DIR:-/run/user/`id -u`}/eww-toggle.lock"
+flock 3
+
+for arg in "$@"; do
+ {
+ eww windows | grep -q "^\\*$arg$" && f=close || f=open
+ eww $f "$arg"
+ } &
+done
+wait