Now lock file even works better

This commit is contained in:
i.ortega 2020-05-09 16:03:55 +02:00
parent 2bb3b1ab86
commit 0ecb2dc78d
2 changed files with 7 additions and 6 deletions

View File

@ -190,14 +190,12 @@ update() { \
# Handle SIGTRAP signals sent by refbar to update the status bar immediately.
trap update TRAP
lockfile="/tmp/dwmbar-lock"
update
while :; do
# Sleep for a minute after changing the status bar before updating it
# again. We run sleep in the background and use wait until it finishes,
# because traps can interrupt wait immediately, but they can't do that
# with sleep.
touch "$lockfile" 2>/dev/null
sleep infinity &
sleep_pid="$!"
wait

View File

@ -1,6 +1,9 @@
#!/usr/bin/env sh
lockfile="/tmp/dwmbar-lock"
p_num=$(pgrep -a busybox | grep "busybox .*/dwmbar.sh" | cut -d ' ' -f 1)
# echo "$p_num"
[ -n "$p_num" ] && rm "$lockfile" 2>/dev/null && kill -s 5 "$p_num"
resetlockfile="/tmp/dwmbar-reset-lock"
[ ! -f "$resetlockfile" ] && {
touch "$resetlockfile"
p_num=$(pgrep -a busybox | grep "busybox .*/dwmbar.sh" | cut -d ' ' -f 1)
[ -n "$p_num" ] && kill -s 5 "$p_num"
rm "$resetlockfile"
}