2020-05-24 20:58:23 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import re
|
|
|
|
import time
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
fans=["fan2", "fan3"]
|
|
|
|
default_fan_speed = 30
|
|
|
|
|
|
|
|
|
|
|
|
def run_fan_check():
|
|
|
|
fan_speed = default_fan_speed
|
|
|
|
sensors_out = subprocess.check_output(['sensors'])
|
|
|
|
sensors_out = sensors_out.decode('UTF-8').splitlines()
|
|
|
|
tdie_temp = [x for x in sensors_out if x.startswith("Tdie")]
|
|
|
|
|
|
|
|
if len(tdie_temp) > 0:
|
|
|
|
temp = tdie_temp[0]
|
|
|
|
temp = float(re.findall(r"^Tdie:\s*\+(.*?)°C.+", temp)[0])
|
2020-06-05 13:23:19 +00:00
|
|
|
# if temp < 50:
|
|
|
|
# fan_speed = 20
|
|
|
|
# if temp < 60:
|
|
|
|
# fan_speed = 30
|
|
|
|
# elif temp < 70:
|
|
|
|
# fan_speed = 40
|
|
|
|
# elif temp < 80:
|
|
|
|
# fan_speed = 60
|
|
|
|
# else:
|
|
|
|
# fan_speed = 100
|
2020-05-29 09:00:20 +00:00
|
|
|
if temp < 60:
|
2020-06-17 21:36:03 +00:00
|
|
|
fan_speed = 60
|
|
|
|
if temp < 60:
|
|
|
|
fan_speed = 60
|
2020-05-29 09:00:20 +00:00
|
|
|
elif temp < 70:
|
2020-05-29 15:57:38 +00:00
|
|
|
fan_speed = 60
|
2020-06-17 21:36:03 +00:00
|
|
|
elif temp < 80:
|
|
|
|
fan_speed = 70
|
2020-05-29 15:57:38 +00:00
|
|
|
else:
|
2020-05-24 20:58:23 +00:00
|
|
|
fan_speed = 100
|
|
|
|
|
2020-06-05 13:23:19 +00:00
|
|
|
print("setting fan speed to " + str(fan_speed) + "%, temp is " + str(temp))
|
2020-05-24 20:58:23 +00:00
|
|
|
for fan in fans:
|
|
|
|
subprocess.run(["liquidctl", "set", fan, "speed", str(fan_speed)])
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
run_fan_check()
|
|
|
|
except:
|
|
|
|
print("There was a problem while running the fan curve")
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
|
|
|
|
# cm-rgb-cli
|
|
|
|
|
|
|
|
# run as casefan.service (systemctl enable casefan)
|