summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxyz <gky44px1999@gmail.com>2022-01-26 16:53:47 -0800
committerxyz <gky44px1999@gmail.com>2022-01-26 16:53:47 -0800
commitd88c60615073279d393150c52a73dfb86d862dcf (patch)
tree8bf0f72678f901fa598b4167728ae6347baab9dd
parentb0927c39cb2c1a4b4c2eaadbe8d5641790a56938 (diff)
sbar, fix bug: pid stored in the file may be taken by another process if sbar is not running
-rwxr-xr-xhome/xyz/.local/bin/sbar4
1 files changed, 2 insertions, 2 deletions
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