Clean text when 100%

This commit is contained in:
Thomas Forgione 2026-03-09 14:25:59 +01:00
parent e28a4b6abe
commit e8aa6f25cd

View File

@ -250,10 +250,13 @@ def monitor_stats():
battery_json = f', "class": "{battery_class}"' if battery_class else ''
battery_json = '{"text": "' + battery_icon + ' ' + "% 4.0f" % battery.percent + '%"' + battery_json + '}'
cpu_percent_text = "% 5.1f" % cpu_percent if cpu_percent <= 99.95 else " 100"
mem_percent_text = "% 5.1f" % mem_percent if mem_percent <= 99.95 else " 100"
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' +
' ' + ''.join([to_bar(x) for x in cpu_values]) + ' ' + cpu_percent_text + '%\n' +
' ' + ''.join([to_bar(x) for x in mem_values]) + ' ' + mem_percent_text + '%\n' +
'  ' + ''.join([to_bar(x) for x in temp_values]) + ' ' + "% 5.1f" % temp + '°\n' +
battery_json
)