summaryrefslogtreecommitdiff
path: root/.config/eww/scripts/toggle
blob: 0a4d38971a3d5409fa508e1883d947c4c9e9ed56 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh

# 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