Created
February 5, 2016 15:30
-
-
Save cglosser/490a9c93f41b9f4b5f49 to your computer and use it in GitHub Desktop.
Replacing the HDD in a recent-ish iMac without an apple-branded disk causes the system to floor the fan RPMs making for a TON of noise. This script manually overrides the HDD fan speed every ten seconds to quiet things down.
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 characters
#!/bin/bash | |
#smartfancontrol.sh | |
#### enter your preferred values here ################## | |
speed_min=2000 #RPM | |
speed_max=5500 #RPM | |
temp_min=46 #degrees celsius | |
temp_max=60 #degrees celsius | |
########## Do not edit below this line ################### | |
while true; do | |
echo 1 > /sys/devices/platform/applesmc.768/fan2_manual | |
temp=$(/usr/sbin/smartctl -A /dev/sda | grep ^194 | awk '{print $10}') | |
if [[ $temp -lt $temp_min ]]; then | |
speed=$speed_min | |
elif [[ $temp -gt $temp_max ]]; then | |
speed=$speed_max | |
else | |
x=$(($speed_max-$speed_min)) | |
y=$(($(($temp-$temp_min))*100)) | |
z=$(($(($temp_max-$temp_min))*100)) | |
a=$(($x*$y/$z)) | |
speed=$(($a+$speed_min)) | |
fi | |
echo $speed >/sys/devices/platform/applesmc.768/fan2_output | |
printf '[ %i C | %i rpm ]\n' $temp $speed | |
sleep 10 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment