63 lines
1,016 B
Bash
Executable file
63 lines
1,016 B
Bash
Executable file
#!/bin/bash
|
|
#ftpfct : Fucking ThinkPad FanConTrol
|
|
# Yep, fancontrol works shit on my machine (kernel fault I think), so let's use
|
|
# ACPI and "kernel controls" (from TP_smapi).
|
|
|
|
FANFILE=/proc/acpi/ibm/fan
|
|
|
|
ACPI='acpi -V'
|
|
|
|
REFRESH=10
|
|
|
|
function set_fan
|
|
{
|
|
echo "level $1" | sudo tee $FANFILE
|
|
}
|
|
|
|
function finish
|
|
{
|
|
set_fan full-speed
|
|
}
|
|
|
|
trap finish EXIT
|
|
|
|
while true; do
|
|
|
|
TEMP=$($ACPI | grep degrees | grep -v critical | cut -d' ' -f4)
|
|
TEMP=$(echo $TEMP | cut -d. -f1)
|
|
echo $TEMP °C
|
|
|
|
#TODO: hysteresis if it becomes fucking annoying jumping around
|
|
|
|
if [ $TEMP -lt 10 ]; then
|
|
xsetroot PROC PROBLEM
|
|
set_fan full_speed
|
|
echo "full speed"
|
|
REFRESH=10
|
|
elif [ $TEMP -lt 46 ]; then
|
|
set_fan 0
|
|
echo "lt 46"
|
|
REFRESH=10
|
|
elif [ $TEMP -lt 56 ]; then
|
|
set_fan 1
|
|
echo "lt 56"
|
|
REFRESH=5
|
|
elif [ $TEMP -lt 66 ]; then
|
|
set_fan 2
|
|
echo "lt 66"
|
|
REFRESH=4
|
|
elif [ $TEMP -lt 70 ]; then
|
|
set_fan 5
|
|
echo "lt 66"
|
|
REFRESH=3
|
|
else
|
|
set_fan full-speed
|
|
echo "full speed"
|
|
REFRESH=2
|
|
fi;
|
|
|
|
sleep $REFRESH
|
|
|
|
done
|
|
|
|
|