Prefer CPU temperature for fan control daemon
This commit is contained in:
parent
bde8e1968b
commit
16b3b5835c
1 changed files with 14 additions and 2 deletions
|
|
@ -154,15 +154,27 @@ def find_hwmon():
|
|||
|
||||
|
||||
def read_temp():
|
||||
preferred_labels = {"Tctl", "Tdie", "CPU", "Core"}
|
||||
|
||||
# First pass: prefer explicit CPU/APU labels across all hwmon devices.
|
||||
# Some systems expose GPU/NVMe hwmon earlier than k10temp; using the first
|
||||
# positive temp1_input can therefore keep the fan off while the CPU heats up.
|
||||
for hwmon_dir in Path("/sys/class/hwmon").glob("hwmon*"):
|
||||
try:
|
||||
for label_file in hwmon_dir.glob("temp*_label"):
|
||||
label = label_file.read_text().strip()
|
||||
if label in ["Tctl", "Tdie", "CPU", "Core"]:
|
||||
if label in preferred_labels:
|
||||
temp_file = label_file.with_name(label_file.name.replace("_label", "_input"))
|
||||
if temp_file.exists():
|
||||
return int(temp_file.read_text().strip()) / 1000.0
|
||||
temp = int(temp_file.read_text().strip())
|
||||
if temp > 0:
|
||||
return temp / 1000.0
|
||||
except (ValueError, IOError):
|
||||
continue
|
||||
|
||||
# Fallback: any positive temp1_input if no labeled CPU/APU source exists.
|
||||
for hwmon_dir in Path("/sys/class/hwmon").glob("hwmon*"):
|
||||
try:
|
||||
temp_file = hwmon_dir / "temp1_input"
|
||||
if temp_file.exists():
|
||||
temp = int(temp_file.read_text().strip())
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue