From 26ceab690dff09d5162443b14adccfbe0e9bcd5d Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 13 May 2026 13:43:42 +0100 Subject: refactor(notifications): drop dismissed-state machinery; pending = visible Set mako default-timeout=0 so notifications stay until acted upon. With auto-timeout off, mako's list IS the pending set, so the $XDG_RUNTIME_DIR/mako-dismissed bridge becomes dead weight. - mako/config: default-timeout=0; drop redundant [urgency=critical] default-timeout=0 override. - Delete dismiss-visible.sh and restore-pending.sh; sway calls makoctl directly (Mod+n=dismiss, Mod+Shift+n=dismiss --all, Mod+Ctrl+n=restore as undo). - Shrink mako-status.sh to a 20-line counter of makoctl list. - Rename mako-history.py -> notification-picker.py; lists only visible, dismisses via makoctl dismiss -n . - Update waybar config.jsonc on-click path. - Update KEYBINDS.md wording (no more 'marks seen' / 'pending set'). --- dot_config/waybar/executable_mako-status.sh | 55 ++++++----------------------- 1 file changed, 10 insertions(+), 45 deletions(-) (limited to 'dot_config/waybar/executable_mako-status.sh') diff --git a/dot_config/waybar/executable_mako-status.sh b/dot_config/waybar/executable_mako-status.sh index 12e4d82..4e9f053 100644 --- a/dot_config/waybar/executable_mako-status.sh +++ b/dot_config/waybar/executable_mako-status.sh @@ -1,56 +1,21 @@ #!/bin/sh -# Waybar status: count of *pending* notifications, where pending = ids in -# 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). +# 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"} -' + printf '{"text":"","tooltip":"mako not installed","class":"off"}\n' exit 0 fi -state=${XDG_RUNTIME_DIR:-/tmp}/mako-dismissed -: >>"$state" +count=$(makoctl list 2>/dev/null | + grep -c '^Notification [0-9][0-9]*:' || true) -# This makoctl has no -f flag; parse the text dump. Each notification -# starts with "Notification N: ". 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 - tmp=$(mktemp) - printf '%s -' "$all_ids" >"$tmp.all" - grep -Fxf "$tmp.all" "$state" >"$tmp" 2>/dev/null || : - mv "$tmp" "$state" - rm -f "$tmp.all" -fi - -if [ -z "$all_ids" ]; then - pending=0 -else - pending=$(printf '%s -' "$all_ids" | grep -Fxvf "$state" | grep -c . || true) -fi - -if [ "$pending" -gt 0 ]; then - printf '{"text":"󰂞 %s","tooltip":"%s pending","class":"pending"} -' \ - "$pending" "$pending" +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"} -' + printf '{"text":"󰂜","tooltip":"no pending notifications","class":"empty"}\n' fi -- cgit v1.3.1