More polishing up
This commit is contained in:
@@ -160,14 +160,14 @@
|
|||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"exec": "$HOME/.config/waybar/scripts/openai-rate.py --window primary",
|
"exec": "$HOME/.config/waybar/scripts/openai-rate.py --window primary",
|
||||||
"exec-if": "test -r ~/.codex/auth.json",
|
"exec-if": "test -r ~/.codex/auth.json",
|
||||||
"format": "5h {}"
|
"format": " {}"
|
||||||
},
|
},
|
||||||
"custom/codex-secondary": {
|
"custom/codex-secondary": {
|
||||||
"interval": 15,
|
"interval": 15,
|
||||||
"return-type": "json",
|
"return-type": "json",
|
||||||
"exec": "$HOME/.config/waybar/scripts/openai-rate.py --window secondary",
|
"exec": "$HOME/.config/waybar/scripts/openai-rate.py --window secondary",
|
||||||
"exec-if": "test -r ~/.codex/auth.json",
|
"exec-if": "test -r ~/.codex/auth.json",
|
||||||
"format": "W {}"
|
"format": " {}"
|
||||||
},
|
},
|
||||||
"custom/backup": {
|
"custom/backup": {
|
||||||
"interval": 60,
|
"interval": 60,
|
||||||
|
|||||||
@@ -81,17 +81,18 @@ def window_label(seconds):
|
|||||||
return "usage"
|
return "usage"
|
||||||
|
|
||||||
minutes = math.ceil(seconds / 60)
|
minutes = math.ceil(seconds / 60)
|
||||||
windows = (
|
if minutes < 90:
|
||||||
(5 * 60, "5h"),
|
return f"{minutes}m"
|
||||||
(24 * 60, "daily"),
|
|
||||||
(7 * 24 * 60, "weekly"),
|
hours = round(minutes / 60)
|
||||||
(30 * 24 * 60, "monthly"),
|
if hours < 36:
|
||||||
(365 * 24 * 60, "annual"),
|
return f"{hours}h"
|
||||||
)
|
|
||||||
for expected, label in windows:
|
days = round(hours / 24)
|
||||||
if expected * 0.95 <= minutes <= expected * 1.05:
|
if days < 365:
|
||||||
return label
|
return f"{days}d"
|
||||||
return "usage"
|
|
||||||
|
return f"{round(days / 365)}y"
|
||||||
|
|
||||||
|
|
||||||
def reset_text(seconds):
|
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"))
|
klass = usage_class(window["used"], rate_limit.get("limit_reached"))
|
||||||
tooltip = [window["tooltip"], f"{window['left']}% remaining", f"source: {source}"]
|
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):
|
def combined_output(data, source):
|
||||||
|
|||||||
Reference in New Issue
Block a user