aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_mako-status.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/waybar/executable_mako-status.sh')
-rw-r--r--dot_config/waybar/executable_mako-status.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/dot_config/waybar/executable_mako-status.sh b/dot_config/waybar/executable_mako-status.sh
new file mode 100644
index 0000000..a2fb792
--- /dev/null
+++ b/dot_config/waybar/executable_mako-status.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Emit waybar JSON with the mako notification count. Falls back to 0 when
+# mako is not running so waybar doesn't blink errors.
+set -eu
+
+if ! command -v makoctl >/dev/null 2>&1; then
+ printf '{"text":"","tooltip":"mako not installed","class":"off"}\n'
+ exit 0
+fi
+
+count=$(makoctl history 2>/dev/null \
+ | grep -c '"summary"' || true)
+pending=$(makoctl list 2>/dev/null \
+ | grep -c '"summary"' || true)
+
+if [ "$pending" -gt 0 ]; then
+ text="!$pending"
+ class="pending"
+elif [ "$count" -gt 0 ]; then
+ text="$count"
+ class="history"
+else
+ text="0"
+ class="empty"
+fi
+
+printf '{"text":"%s","tooltip":"%s pending / %s history","class":"%s"}\n' \
+ "$text" "$pending" "$count" "$class"