From b1758ba74b084b8a72dd98e64d20480c41f3a9b6 Mon Sep 17 00:00:00 2001 From: marchwicki <57815103+marchwicki@users.noreply.github.com> Date: Sun, 21 May 2023 06:31:39 -0400 Subject: [PATCH] check for CPU lable if no coretemp (#513) Attempt to use "CPU" label before falling back to the first sensor. --- auto_cpufreq/core.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 8f67e45..0c4e7ab 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -1156,8 +1156,19 @@ def sysinfo(): cpu_temp_index = core_temp_labels.index(f"Core {core}") temp_per_cpu[i] = core_temp["coretemp"][cpu_temp_index].current else: - temp = list(psutil.sensors_temperatures()) - temp_per_cpu = [core_temp[temp[0]][0].current] * online_cpu_count + # iterate over all sensors + for sensor in core_temp: + # iterate over all temperatures in the current sensor + for temp in core_temp[sensor]: + if temp.label == 'CPU': + temp_per_cpu = [temp.current] * online_cpu_count + break + else: + continue + break + else: # if 'CPU' label not found in any sensor, use first available temperature + temp = list(core_temp.keys())[0] + temp_per_cpu = [core_temp[temp][0].current] * online_cpu_count except Exception as e: print(repr(e)) pass @@ -1233,4 +1244,4 @@ def not_running_daemon_check(): exit(1) elif os.getenv("PKG_MARKER") == "SNAP" and dcheck == "disabled": daemon_not_running_msg() - exit(1) \ No newline at end of file + exit(1)