aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_mako-status.sh
blob: a2fb7922e61b1feeedb186269dd2e7a4b433cffc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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"