aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/waybar
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:29 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:29 +0100
commitdff09010412af5dc3a15b20f20aa1801eda3db5f (patch)
tree6461bdc354e63147d970fc6b39b4e9637a3fe7de /dot_config/waybar
parente331fd63eaa51a51a6af06560bbe226a6d47fa16 (diff)
downloaddotfiles-dff09010412af5dc3a15b20f20aa1801eda3db5f.tar.gz
dotfiles-dff09010412af5dc3a15b20f20aa1801eda3db5f.tar.bz2
dotfiles-dff09010412af5dc3a15b20f20aa1801eda3db5f.zip
fix(waybar): notification picker also lists currently-visible bubbles
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.
Diffstat (limited to 'dot_config/waybar')
-rw-r--r--dot_config/waybar/executable_mako-history.py26
1 files 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)