dotfiles/Utils/ftpfct.sh

64 lines
1,016 B
Bash
Raw Normal View History

#!/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'
2013-12-02 22:37:14 +00:00
REFRESH=10
function set_fan
{
2014-01-02 22:55:00 +00:00
echo "level $1" | sudo tee $FANFILE
}
2013-11-26 20:13:30 +00:00
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"
2013-12-02 22:37:14 +00:00
REFRESH=10
2016-02-19 11:09:15 +00:00
elif [ $TEMP -lt 48 ]; then
set_fan 0
echo "lt 46"
2013-12-02 22:37:14 +00:00
REFRESH=10
elif [ $TEMP -lt 56 ]; then
2016-02-19 11:09:15 +00:00
set_fan 2
echo "lt 56"
2013-12-02 22:37:14 +00:00
REFRESH=5
elif [ $TEMP -lt 66 ]; then
2015-11-11 14:27:47 +00:00
set_fan 4
2013-11-26 20:13:30 +00:00
echo "lt 66"
2013-12-02 22:37:14 +00:00
REFRESH=4
2013-11-26 20:13:30 +00:00
elif [ $TEMP -lt 70 ]; then
set_fan 5
echo "lt 66"
2013-12-02 22:37:14 +00:00
REFRESH=3
else
set_fan full-speed
echo "full speed"
2013-12-02 22:37:14 +00:00
REFRESH=2
fi;
2013-12-02 22:37:14 +00:00
sleep $REFRESH
done