Created
May 5, 2016 19:48
Revisions
-
mendelgusmao created this gist
May 5, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ minSpeed=1500 maxSpeed=5500 highTemp=70 normalTemp=40 output=/sys/devices/platform/applesmc.768/fan1_output manual=/sys/devices/platform/applesmc.768/fan1_manual currentSpeed=$(cat $output) [ "$1" = "" ] && echo $currentSpeed && exit 0 if [ "$1" = "auto" ]; then currentTemp=$(sensors | awk -F'[^0-9]*' '/Core/{sum = sum + $3; total = total + 1}END{OFMT = "%.0f"; print sum / total}') newSpeed=$(echo "$minSpeed + (($maxSpeed - $minSpeed) / ($highTemp - $normalTemp) * ($currentTemp - $normalTemp))" | bc | cut -d. -$ if [ $newSpeed -eq $currentSpeed ]; then exit 0 fi else newSpeed=$1 fi bash -c "echo 1 > $manual" bash -c "echo $newSpeed > $output" #sudo bash -c "echo 0 > $manual" echo "$currentSpeed > $(cat $output) @ $currentTemp"