Support for desktop

This commit is contained in:
Thomas Forgione 2025-04-16 09:52:35 +02:00
parent 75eea377c6
commit d2383ed1b9
2 changed files with 20 additions and 11 deletions

View File

@ -164,25 +164,30 @@ def monitor_stats():
cpu_values[-1] = cpu_percent cpu_values[-1] = cpu_percent
mem_values[-1] = mem_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: if battery is None:
battery_class = 'charging' battery_json = '{"text": "", "class": "hidden"}'
elif battery.percent < 30.0:
battery_class = 'low'
elif battery.percent < 15.0:
battery_class = 'critical'
else: 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: with open('.stat.txt', 'w') as f:
f.write( f.write(
' ' + ''.join([to_bar(x) for x in cpu_values]) + ' ' + "% 5.1f"%cpu_percent + '%\n' + ' ' + ''.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' + ' ' + ''.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
) )

View File

@ -125,6 +125,10 @@ button:hover {
color: @red; color: @red;
} }
#custom-battery.hidden {
padding: 0;
}
#network { #network {
color: @yellow; color: @yellow;
} }