Fix popover: show all accounts with per-row bars and a dark window
The native tooltip never rendered. Two waybar quirks stacked: 1. custom/ocd had tooltip-format set. For a custom module with return-type json, a tooltip-format overrides the JSON tooltip field and waybar falls back to the label text (Waybar #3022). So the popover showed the single rotating account label instead of all accounts. Remove tooltip-format; waybar now uses the daemon's JSON tooltip field. 2. The daemon joined tooltip lines with newline. waybar custom modules break on newline (the tooltip vanishes; Waybar #3153). The wiki says to use carriage return instead. Switch the separator to \r. Reformat the tooltip so each limit (5h/1w/1m) is on its own row under the account, with a blank row between accounts for a bigger gap, as requested. Add a dark tooltip background. waybar scopes tooltip CSS globally (wiki / PR #4930): style all bar tooltips with the existing theme dark color @background/@foreground so the popover matches the bar instead of rendering backgroundless.
This commit is contained in:
parent
c4647dda6b
commit
09668a7c9a
@ -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"
|
||||
},
|
||||
@ -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;
|
||||
}
|
||||
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user