diff options
Diffstat (limited to 'dot_config')
| -rw-r--r-- | dot_config/waybar/executable_mako-status.sh | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/dot_config/waybar/executable_mako-status.sh b/dot_config/waybar/executable_mako-status.sh index a4fdd31..de9b215 100644 --- a/dot_config/waybar/executable_mako-status.sh +++ b/dot_config/waybar/executable_mako-status.sh @@ -1,7 +1,7 @@ #!/bin/sh # Waybar status: count of *pending* notifications, where pending = ids in -# mako's history that have NOT been explicitly dismissed by the user via -# Mod+n / Mod+Shift+n / the history picker. +# mako's history/list that have NOT been explicitly dismissed by the user +# via Mod+n / Mod+Shift+n / the history picker. # # State file: $XDG_RUNTIME_DIR/mako-dismissed (per-session, plain id list). @@ -16,13 +16,15 @@ fi state=${XDG_RUNTIME_DIR:-/tmp}/mako-dismissed : >>"$state" -# Visible notifications also count as pending (they aren't in history yet). -visible_ids=$(makoctl list -f '%i' 2>/dev/null || true) -history_ids=$(makoctl history -f '%i' 2>/dev/null || true) -all_ids=$(printf '%s -%s -' "$visible_ids" "$history_ids" \ - | grep -E '^[0-9]+$' | sort -u || true) +# This makoctl has no -f flag; parse the text dump. Each notification +# starts with "Notification N: <summary>". Visible bubbles live in +# `list`, closed ones in `history`; their id-spaces are disjoint. +extract_ids() { + makoctl "$1" 2>/dev/null \ + | sed -n 's/^Notification \([0-9][0-9]*\):.*/\1/p' +} + +all_ids=$( { extract_ids list; extract_ids history; } | sort -un) # Prune stale ids (no longer present in mako) from the dismissed file. if [ -s "$state" ] && [ -n "$all_ids" ]; then |
