More polishing up

This commit is contained in:
2026-06-15 00:00:56 -05:00
parent f04e24b64d
commit 319db74bce
2 changed files with 15 additions and 14 deletions
+2 -2
View File
@@ -160,14 +160,14 @@
"return-type": "json",
"exec": "$HOME/.config/waybar/scripts/openai-rate.py --window primary",
"exec-if": "test -r ~/.codex/auth.json",
"format": "5h {}"
"format": " {}"
},
"custom/codex-secondary": {
"interval": 15,
"return-type": "json",
"exec": "$HOME/.config/waybar/scripts/openai-rate.py --window secondary",
"exec-if": "test -r ~/.codex/auth.json",
"format": "W {}"
"format": " {}"
},
"custom/backup": {
"interval": 60,
+13 -12
View File
@@ -81,17 +81,18 @@ def window_label(seconds):
return "usage"
minutes = math.ceil(seconds / 60)
windows = (
(5 * 60, "5h"),
(24 * 60, "daily"),
(7 * 24 * 60, "weekly"),
(30 * 24 * 60, "monthly"),
(365 * 24 * 60, "annual"),
)
for expected, label in windows:
if expected * 0.95 <= minutes <= expected * 1.05:
return label
return "usage"
if minutes < 90:
return f"{minutes}m"
hours = round(minutes / 60)
if hours < 36:
return f"{hours}h"
days = round(hours / 24)
if days < 365:
return f"{days}d"
return f"{round(days / 365)}y"
def reset_text(seconds):
@@ -183,7 +184,7 @@ def selected_window_output(data, source, selector):
klass = usage_class(window["used"], rate_limit.get("limit_reached"))
tooltip = [window["tooltip"], f"{window['left']}% remaining", f"source: {source}"]
waybar(f"{window['left']}%", klass, "\n".join(tooltip))
waybar(f"{window['left']}% {window['label']}", klass, "\n".join(tooltip))
def combined_output(data, source):