commit ba0a0ce4aec1d1ab8e4b8094bff9ff67e59fe581
parent 99b90161e266de187124c794a1cb41256845cba7
Author: Cem Keylan <cem@ckyln.com>
Date: Sat, 21 Dec 2019 21:22:57 +0300
add killexisting function
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/sb b/sb
@@ -35,7 +35,10 @@ fi
for func in "$FUNCPATH/"* ; do . "$func"; done
if [ -z "$nobar" ]; then
- [ -e "/tmp/sb-$USER.pid" ] && printf "ERROR: sb is already running\\nIf you think otherwise, remove /tmp/sb-$USER.pid manually.\\n" && exit 1
+ if [ -e "/tmp/sb-$USER.pid" ] ; then
+ [ -z "$KILLEXISTING" ] && printf "ERROR: sb is already running\\nIf you think otherwise, remove /tmp/sb-$USER.pid manually.\\n" && exit 1
+ kill "$(cat "/tmp/sb-$USER.pid")" 2>/dev/null
+ fi
printf "$$\\n" > "/tmp/sb-$USER.pid"
fi
diff --git a/sbrc.example b/sbrc.example
@@ -20,6 +20,11 @@ DATE="%a %d %b %Y %H:%M"
# Refresh Interval. Default: "1"
SLEEPTIME=""
+# If the variable is nonzero it will kill the existing
+# sb instance, if the variable is empty sb will exit with
+# exit-code 1.
+KILLEXISTING=""
+
# Add the modules you want to run in the bar. Do not add the "sb_" part
# If you want to add the battery module, type battery instead of sb_battery
# To switch from top bar to bottom bar add DELIMETER=";" to the beginning of the