From dff09010412af5dc3a15b20f20aa1801eda3db5f Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 13 May 2026 13:43:29 +0100 Subject: fix(waybar): notification picker also lists currently-visible bubbles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit makoctl list and makoctl history are disjoint — visible notifications aren't in history yet. The picker was only reading history, so it came up empty whenever the bar showed pending bubbles that were still on screen. Merge both lists, dedupe by id, visible first. --- dot_config/waybar/executable_mako-history.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/dot_config/waybar/executable_mako-history.py b/dot_config/waybar/executable_mako-history.py index d12ea6f..9f4a50d 100644 --- a/dot_config/waybar/executable_mako-history.py +++ b/dot_config/waybar/executable_mako-history.py @@ -21,13 +21,16 @@ RECORD_RE = re.compile(r"^Notification (\d+):\s*$") FIELD_RE = re.compile(r"^ ([A-Za-z][A-Za-z ]*?):\s*(.*)$") -def parse_history() -> list[dict]: +def _run_makoctl(subcmd: str) -> str: try: - out = subprocess.run( - ["makoctl", "history"], capture_output=True, text=True, check=True + return subprocess.run( + ["makoctl", subcmd], capture_output=True, text=True, check=True ).stdout except (subprocess.CalledProcessError, FileNotFoundError): - return [] + return "" + + +def _parse_block(out: str) -> list[dict]: notifs: list[dict] = [] cur: dict | None = None last_field: str | None = None @@ -47,7 +50,6 @@ def parse_history() -> list[dict]: cur[key] = m.group(2) last_field = key continue - # Body / continuation lines (mako indents with 8 spaces). if last_field == "body" and line.startswith(" "): cur["body"] = (cur.get("body", "") + " " + line.strip()).strip() if cur is not None: @@ -55,6 +57,20 @@ def parse_history() -> list[dict]: return notifs +def parse_history() -> list[dict]: + """Return visible + history notifications, deduped by id, visible first.""" + visible = _parse_block(_run_makoctl("list")) + history = _parse_block(_run_makoctl("history")) + seen: set[int] = set() + out: list[dict] = [] + for n in visible + history: + if n["id"] in seen: + continue + seen.add(n["id"]) + out.append(n) + return out + + def load_dismissed() -> set[str]: STATE.parent.mkdir(parents=True, exist_ok=True) STATE.touch(exist_ok=True) -- cgit v1.3.1