More polishing up
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user