diff --git a/hypr/hyprscript b/hypr/hyprscript index 0a01ed4..99e2235 100755 --- a/hypr/hyprscript +++ b/hypr/hyprscript @@ -164,25 +164,30 @@ def monitor_stats(): cpu_values[-1] = cpu_percent mem_values[-1] = mem_percent - battery_index = round(battery.percent / 10) - battery_icon = batteries_charging[battery_index] if battery.power_plugged else batteries[battery_index] - if battery.power_plugged: - battery_class = 'charging' - elif battery.percent < 30.0: - battery_class = 'low' - elif battery.percent < 15.0: - battery_class = 'critical' + if battery is None: + battery_json = '{"text": "", "class": "hidden"}' else: - battery_class = None + battery_index = round(battery.percent / 10) + battery_icon = batteries_charging[battery_index] if battery.power_plugged else batteries[battery_index] - battery_json = f', "class": "{battery_class}"' if battery_class else '' + if battery.power_plugged: + battery_class = 'charging' + elif battery.percent < 30.0: + battery_class = 'low' + elif battery.percent < 15.0: + battery_class = 'critical' + else: + battery_class = None + + battery_json = f', "class": "{battery_class}"' if battery_class else '' + battery_json = '{"text": "' + battery_icon + ' ' + "% 3.0f"%battery.percent + '%"' + battery_json + '}' with open('.stat.txt', 'w') as f: f.write( ' ' + ''.join([to_bar(x) for x in cpu_values]) + ' ' + "% 5.1f"%cpu_percent + '%\n' + ' ' + ''.join([to_bar(x) for x in mem_values]) + ' ' + "% 5.1f"%mem_percent + '%\n' + - '{"text": "' + battery_icon + ' ' + "% 3.0f"%battery.percent + '%"' + battery_json + '}' + battery_json ) diff --git a/waybar/style.css b/waybar/style.css index 0353832..d8dfb1e 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -125,6 +125,10 @@ button:hover { color: @red; } +#custom-battery.hidden { + padding: 0; +} + #network { color: @yellow; }