dotfiles/Utils/ftpfct.sh
2013-11-26 21:13:30 +01:00

56 lines
937 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'
function set_fan
{
echo "level $1" | sudo tee $FANFILE > /dev/null
}
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"
elif [ $TEMP -lt 46 ]; then
set_fan 0
echo "lt 46"
elif [ $TEMP -lt 56 ]; then
set_fan 1
echo "lt 56"
elif [ $TEMP -lt 66 ]; then
set_fan 2
echo "lt 66"
elif [ $TEMP -lt 70 ]; then
set_fan 5
echo "lt 66"
else
set_fan full-speed
echo "full speed"
fi;
sleep 10
done