use psutil for cpu temp (#200)
This commit is contained in:
@@ -160,14 +160,16 @@ def read_ext_sensors():
|
||||
|
||||
|
||||
def check_cpu_temp():
|
||||
full_cmd = f"awk '{{printf (\"%.2f\\n\", $1/1000); }}' $(for zone in /sys/class/thermal/thermal_zone*/; do grep -iq \"{config.cpu_thermal_zone}\" \"${{zone}}type\" && echo \"${{zone}}temp\"; done)"
|
||||
try:
|
||||
p = subprocess.Popen(full_cmd, shell=True, stdout=subprocess.PIPE).communicate()[0]
|
||||
cpu_temp = p.decode("utf-8").strip().replace(",", ".")
|
||||
except Exception:
|
||||
cpu_temp = None if config.use_availability else 0
|
||||
|
||||
return cpu_temp
|
||||
temps = psutil.sensors_temperatures()
|
||||
if not temps or "coretemp" not in temps:
|
||||
raise ValueError("CPU temperature sensor not found.")
|
||||
|
||||
cpu_temp = temps["coretemp"][0].current
|
||||
return round(cpu_temp, 2)
|
||||
except Exception as e:
|
||||
print(f"Error reading CPU temperature: {e}")
|
||||
return None if config.use_availability else 0
|
||||
|
||||
|
||||
def check_sys_clock_speed():
|
||||
|
||||
Reference in New Issue
Block a user