aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar/executable_mako-status.sh
blob: 4e9f0538dea22f4d4cf75e6e16fcd35310c27054 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# Waybar status: count of currently-visible mako notifications. With
# default-timeout=0 in mako/config, "visible" == "pending"; once a
# notification is dismissed it's gone and never comes back.

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 list 2>/dev/null |
  grep -c '^Notification [0-9][0-9]*:' || true)

if [ "$count" -gt 0 ]; then
  printf '{"text":"󰂞 %s","tooltip":"%s pending","class":"pending"}\n' \
    "$count" "$count"
else
  printf '{"text":"󰂜","tooltip":"no pending notifications","class":"empty"}\n'
fi