diff options
| author | 2026-05-13 13:43:18 +0100 | |
|---|---|---|
| committer | 2026-05-13 13:43:18 +0100 | |
| commit | 9859c0ab03e16d64080c44d559df737a0b5771b3 (patch) | |
| tree | 5f0de2fd1ec5b3a3432a23d9bf6779bfe678acb8 /dot_config/waybar | |
| parent | 8bd48cee6cda315501db1697bc8101ec42b5cc88 (diff) | |
| download | dotfiles-9859c0ab03e16d64080c44d559df737a0b5771b3.tar.gz dotfiles-9859c0ab03e16d64080c44d559df737a0b5771b3.tar.bz2 dotfiles-9859c0ab03e16d64080c44d559df737a0b5771b3.zip | |
feat(waybar): add mako notification counter module
New mako-status.sh emits JSON with pending / history counts. Click to
dismiss latest, right-click to dismiss all, middle-click to restore the
last dismissed notification.
Diffstat (limited to 'dot_config/waybar')
| -rw-r--r-- | dot_config/waybar/config.jsonc | 11 | ||||
| -rw-r--r-- | dot_config/waybar/executable_mako-status.sh | 28 |
2 files changed, 39 insertions, 0 deletions
diff --git a/dot_config/waybar/config.jsonc b/dot_config/waybar/config.jsonc index 45d0bfc..46413ac 100644 --- a/dot_config/waybar/config.jsonc +++ b/dot_config/waybar/config.jsonc @@ -17,6 +17,7 @@ "clock", "idle_inhibitor", "privacy", + "custom/notifications", "tray", ], @@ -152,4 +153,14 @@ { "type": "audio-in", "tooltip": true }, ], }, + + "custom/notifications": { + "exec": "~/.config/waybar/mako-status.sh", + "return-type": "json", + "interval": 2, + "on-click": "makoctl dismiss", + "on-click-right": "makoctl dismiss --all", + "on-click-middle": "makoctl restore", + "tooltip": true, + }, } 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" |
