From 7ff798534a6fb9c99611d18ee22757346798ef61 Mon Sep 17 00:00:00 2001
From: Thomas Voss <mail@thomasvoss.com>
Date: Wed, 23 Aug 2023 06:47:03 +0300
Subject: eww: Add an eww configuration

---
 .config/eww/scripts/toggle | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100755 .config/eww/scripts/toggle

(limited to '.config/eww/scripts/toggle')

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
-- 
cgit v1.2.3