diff options
Diffstat (limited to 'dot_config/waybar/executable_restore-pending.sh')
| -rw-r--r-- | dot_config/waybar/executable_restore-pending.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/dot_config/waybar/executable_restore-pending.sh b/dot_config/waybar/executable_restore-pending.sh new file mode 100644 index 0000000..53da3f4 --- /dev/null +++ b/dot_config/waybar/executable_restore-pending.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Restore the most recently closed mako notification and remove its id +# from the dismissed-set so it counts as pending again. + +set -eu + +state=${XDG_RUNTIME_DIR:-/tmp}/mako-dismissed +: >>"$state" + +command -v makoctl >/dev/null 2>&1 || exit 0 + +# mako's history is most-recent-first; the next restore() target is the +# top of the list at the time of the call. +top_id=$(makoctl history -f '%i' 2>/dev/null | head -n1 || true) +makoctl restore || true + +if [ -n "${top_id:-}" ] && [ -s "$state" ]; then + tmp=$(mktemp) + grep -Fxv "$top_id" "$state" >"$tmp" || : + mv "$tmp" "$state" +fi |
