From 81bb55f1857227b286c0d8ecfee015ed54f0888e Mon Sep 17 00:00:00 2001 From: Sravan Balaji Date: Sun, 29 Dec 2024 13:46:32 -0500 Subject: [PATCH] Idle Inhibitor Active on Startup - Make killall waybar fail silently if waybar isn't already running - Update launch script to run in foreground - Use verbose version of waybar CLI args - Automatically restart waybar if it exits with non 143 (SIGTERM) exit code so random crashes (e.g., when opening LibreOffice or some games) don't persist and bar gets restarted --- README.org | 19 ++++++++++++++----- waybar/config.jsonc | 2 +- waybar/launch.sh | 17 +++++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.org b/README.org index 16c400a..fea0e3c 100644 --- a/README.org +++ b/README.org @@ -595,11 +595,20 @@ static const Button buttons[] = { ** Launch Script #+BEGIN_SRC shell :shebang #!/usr/bin/env bash :tangle waybar/launch.sh -killall waybar +killall waybar || true -/usr/bin/waybar \ - -c $HOME/.config/dwl/waybar/config.jsonc \ - -s $HOME/.config/dwl/waybar/style.css & +until /usr/bin/waybar \ + --config $HOME/.config/dwl/waybar/config.jsonc \ + --style $HOME/.config/dwl/waybar/style.css; +do + if [ $? -ne 143 ]; then + echo "Dwl Waybar stopped with exit code $?. Respawning..." >&2; + sleep 1; + else + echo "Dwl Waybar manually killed with SIGTERM"; + break; + fi +done #+END_SRC ** Start Configuration @@ -979,7 +988,7 @@ fi "tooltip": true, "tooltip-format-activated": "Idle Inhibitor: {status}", "tooltip-format-deactivated": "Idle Inhibitor: {status}", - "start-activated": false, + "start-activated": true, }, #+END_SRC diff --git a/waybar/config.jsonc b/waybar/config.jsonc index a3cd045..42109a5 100644 --- a/waybar/config.jsonc +++ b/waybar/config.jsonc @@ -177,7 +177,7 @@ "tooltip": true, "tooltip-format-activated": "Idle Inhibitor: {status}", "tooltip-format-deactivated": "Idle Inhibitor: {status}", - "start-activated": false, + "start-activated": true, }, "memory": { diff --git a/waybar/launch.sh b/waybar/launch.sh index 47eb919..cc43455 100755 --- a/waybar/launch.sh +++ b/waybar/launch.sh @@ -1,6 +1,15 @@ #!/usr/bin/env bash -killall waybar +killall waybar || true -/usr/bin/waybar \ - -c $HOME/.config/dwl/waybar/config.jsonc \ - -s $HOME/.config/dwl/waybar/style.css & +until /usr/bin/waybar \ + --config $HOME/.config/dwl/waybar/config.jsonc \ + --style $HOME/.config/dwl/waybar/style.css; +do + if [ $? -ne 143 ]; then + echo "Dwl Waybar stopped with exit code $?. Respawning..." >&2; + sleep 1; + else + echo "Dwl Waybar manually killed with SIGTERM"; + break; + fi +done