From d88c60615073279d393150c52a73dfb86d862dcf Mon Sep 17 00:00:00 2001 From: xyz Date: Wed, 26 Jan 2022 16:53:47 -0800 Subject: sbar, fix bug: pid stored in the file may be taken by another process if sbar is not running --- home/xyz/.local/bin/sbar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'home/xyz/.local/bin/sbar') diff --git a/home/xyz/.local/bin/sbar b/home/xyz/.local/bin/sbar index e927b9d3..0a80dd4d 100755 --- a/home/xyz/.local/bin/sbar +++ b/home/xyz/.local/bin/sbar @@ -8,9 +8,9 @@ vpn_fifo="$XDG_CACHE_HOME/sbar_vpn_fifo" sec=0 # exit if sbar is already running, fix when startx in another tty, the other tty sbar not working -# maybe try dwmblocks's approach of using `pidof -x sbar`, so can run different sbar in different tty +# maybe try dwmblocks's approach of using `kill $(pidof -x sbar)`, so can run different sbar in different tty # but then vpn_fifo becomes a problem too, not sure how to solve -if ! [ -e "$pid_file" ] || ! ps -p "$(cat "$XDG_CACHE_HOME/pidofbar")"; then +if ! [ -e "$pid_file" ] || ! pidof -qsx sbar -o "$$"; then printf '%s' "$$" > "$pid_file" else exit -- cgit v1.2.3-70-g09d2