aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_mako-status.sh
blob: 791aabe847be7c449e493934158fd4d77b24a05e (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
#!/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 '^Notification ' || true)
pending=$(makoctl list 2>/dev/null | grep -c '^Notification ' || true)

if [ "$pending" -gt 0 ]; then
  text="󰂞 $pending"
  class="pending"
elif [ "$count" -gt 0 ]; then
  text="󱇨 $count"
  class="history"
else
  text="󰂜"
  class="empty"
fi

printf '{"text":"%s","tooltip":"%s pending / %s history","class":"%s"}\n' \
  "$text" "$pending" "$count" "$class"