Temp, no gather in firefox

This commit is contained in:
2025-11-13 09:05:14 +01:00
parent 52683079ef
commit 7bed37eb36
4 changed files with 23 additions and 3 deletions

View File

@@ -200,18 +200,28 @@ def monitor_stats():
cpu_values = [0] * 10
mem_values = [0] * 10
temp_values = [0] * 10
min_temp = 45
max_temp = 90
while True:
cpu_percent = psutil.cpu_percent(interval=2)
mem_percent = psutil.virtual_memory().percent
battery = psutil.sensors_battery()
temps = psutil.sensors_temperatures(fahrenheit=False).get('k10temp')
temp = max([x.current for x in temps if x.label != 'Tctl'])
temp_percent = 100 * min(max([temp - min_temp, 0]) / (max_temp - min_temp), 1)
for i in range(len(cpu_values) - 1):
cpu_values[i] = cpu_values[i+1]
mem_values[i] = mem_values[i+1]
temp_values[i] = temp_values[i+1]
cpu_values[-1] = cpu_percent
mem_values[-1] = mem_percent
temp_values[-1] = temp_percent
if battery is None:
battery_json = '{"text": "", "class": "hidden"}'
@@ -235,6 +245,7 @@ def monitor_stats():
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 temp_values]) + ' ' + "% 5.1f" % temp + '°\n' +
battery_json
)