diff --git a/config/waybar-config.jsonc b/config/waybar-config.jsonc index 3b5cf17..898fc08 100644 --- a/config/waybar-config.jsonc +++ b/config/waybar-config.jsonc @@ -21,7 +21,9 @@ "return-type": "json", "interval": 1, "format": "{}", - "tooltip-format": "{}", + // No "tooltip-format": waybar uses the JSON "tooltip" field written by + // the daemon. Setting tooltip-format here overrides it and falls back to + // the label text (Waybar issue #3022). "on-click": "~/.config/waybar/scripts/ocd-waybar-ctl advance", "on-click-right": "~/.config/waybar/scripts/ocd-waybar-ctl lock" }, \ No newline at end of file diff --git a/config/waybar-style.css b/config/waybar-style.css index 1b7a28c..499b5e5 100644 --- a/config/waybar-style.css +++ b/config/waybar-style.css @@ -9,4 +9,19 @@ } #custom-ocd.ocd-locked { color: #5aa6e0; +} + +/* Dark popover background for the ocd tooltip window. + Waybar scopes tooltip styles globally: this rule applies to every + tooltip in the bar, not just ours (Waybar wiki / PR #4930). It uses + @background / @foreground, the same dark theme color the rest of + the bar already uses (imported by omarchy's theme file), so the + change matches the bar instead of introducing a new color. + Also make the tooltip font monospace so the block-char bars line up. */ +tooltip { + background-color: @background; + color: @foreground; + padding: 6px 8px; + border-radius: 6px; + font-family: monospace; } \ No newline at end of file diff --git a/scripts/ocd-waybar b/scripts/ocd-waybar index 73c8d94..cfdebff 100755 --- a/scripts/ocd-waybar +++ b/scripts/ocd-waybar @@ -256,14 +256,36 @@ def render_tooltip(report, index, locked, now): head = "opencode limits" if gen: head += f" \u00b7 updated {rel_ago(report.get('generated_at'), now)}" - lines = [head, ""] + # Each window (5h/1w/1m) gets its own row; a blank row separates + # accounts for a bigger gap. Waybar custom-module tooltips need \r + # for line breaks (\n makes the tooltip vanish; see Waybar #3153). + windows = (("usage_5h", "5h"), ("usage_week", "1w"), ("usage_month", "1m")) + blocks = [head, ""] + cur = index % len(accounts) for i, acct in enumerate(accounts): - marker = "\u25b8 " if i == (index % len(accounts)) else " " - # The lock emoji belongs only to the currently displayed row. - row_locked = locked and i == (index % len(accounts)) - body = render_account_line(acct, now, row_locked, markup=TOOLTIP_MARKUP, with_name=True) - lines.append(f"{marker}{body}") - return "\n".join(lines) + is_cur = i == cur + marker = "\u25b8 " if is_cur else " " + row_locked = locked and is_cur + nm = (acct or {}).get("account") or "" + lock = " \U0001f512" if row_locked else "" + bal = balance_str(acct or {}) + age = rel_ago((acct or {}).get("fetched_at"), now) + blocks.append(f"{marker}{nm}{lock} {bal} \u00b7 {age}") + limits = (acct or {}).get("limits") or {} + for key, wl in windows: + f = frame_get(limits, key) + if f is None: + pct = 0.0 + status = None + reset = "\u2014" + else: + pct = pct_of(f) + status = f.get("status") + reset = rel_reset(f.get("resets_at"), now) + bar = bar_plain(pct, status, row_locked) + blocks.append(f" {wl} [{int(round(pct)):>3}%] {bar} {reset}") + blocks.append("") + return "\r".join(blocks) def write_state(text, tooltip, klass):