-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiet-fan
executable file
·56 lines (38 loc) · 1.46 KB
/
quiet-fan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
#--- DEVICES
CPU_TEMP_DEVICE_CORE1=/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input
CPU_TEMP_DEVICE_CORE2=/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp2_input
CPU_TEMP_DEVICE_CORE3=/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp3_input
CPU_TEMP_DEVICE_CORE4=/sys/devices/platform/coretemp.0/hwmon/hwmon1/temp4_input
FAN_SPEED_DEVICE=/sys/devices/platform/nct6775.656/hwmon/hwmon3/pwm1
#--- END DEVICES
#--- CONFIGURATION SETTINGS
# Temperature at which we start ramping up the fan RPMs
CPU_TEMP_MAX=50
# Fans stop below a certain PWM setting. Make sure this is higher than that.
FAN_SPEED_MIN=60
# Timeout values for various states' waiting
HOLDING_TIMEOUT_AFTER_COOLING=60
HOLDING_TIMEOUT_AFTER_SEARCHING=300
COOLING_TIMEOUT_WHILE_COOLING=5
SEARCHING_TIMEOUT_WHILE_SEARCHING=30
# CPU load below which we'll try to search for lower fan speeds
# 80 corresponds to a load of 0.8
CPU_LOAD_THRESHOLD=80
# During searching, how much can the temp go up by before we bail?
ALLOWED_TEMP_INCREASE=3
#--- END CONFIGURATION SETTINGS
#--- MAIN
# Enable PWM
echo 1 > ${FAN_SPEED_DEVICE}_enable
SCRIPT_HOME=$(dirname $0)
. $SCRIPT_HOME/quiet-fan-lib.sh
STATE='holding'
set_timeout 2
set_fan 128
while true; do
$STATE
state_override
printf "CPU: %s FAN: %-5s LOAD: %-4s STATE: %-15s TIMEOUT: %s NOW: %s COUNTDOWN: %s\n" "$(get_cpu_temp)" "$(get_fan)" "$(get_cpu_load)" "$STATE" "$TIMEOUT" "$(_get_now)" "$((TIMEOUT - $(_get_now)))"
sleep 1
done