-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfanManager.sh
executable file
·78 lines (75 loc) · 1.4 KB
/
fanManager.sh
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Information:
# Params:
# $1 = Manual high temp
# $2 = Seconds between updates
# Needs root
# Only for Lenovo-PCs
# Following programms should be available:
# sensors
# Variables
timeout=$2
if [[ -z $timeout ]]
then
timeout=3
fi
disengaged=0
man_high_temp=$1
# Funcitons
check_last_rc () {
rc=$?
if [ $rc -ne 0 ]
then
echo "Could not execute programm. Do you granted root permissions? Aborting!"
exit 1
fi
}
get_current_temp () {
echo $( sensors | grep 'Core 0' | awk '{print $3}' | sed 's/[^0-9.]*//g' )
}
get_high_temp () {
if [[ -z $man_high_temp ]]
then
echo $( sensors | grep 'Core 0' | awk '{print $6}' | sed 's/[^0-9.]*//g' )
else
echo $man_high_temp
fi
}
disengage_fan () {
echo "Fan-Status: disengaged"
sudo bash -c "echo level disengaged > /proc/acpi/ibm/fan"
disengaged=1
check_last_rc
}
reset_fan () {
echo "Fan-Status: auto"
sudo bash -c "echo level auto > /proc/acpi/ibm/fan"
disengaged=0
check_last_rc
}
print_cpu_temp () {
echo "Current temp: " $( get_current_temp )
}
# Code
echo "CPU-Infos:"
echo "Current temp: " $( get_current_temp )
echo "High temp: " $( get_high_temp )
echo "Seconds between updates: " $timeout
reset_fan
while [ 1 ]
do
print_cpu_temp
if [[ "$( get_current_temp )" > "$( get_high_temp )" ]]
then
if [ $disengaged -eq 0 ]
then
disengage_fan
fi
else
if [ $disengaged -eq 1 ]
then
reset_fan
fi
fi
sleep $timeout
done