#!/bin/bash # # Get current HDD temperature. You need TemperatureMonitor by Marcel Bresink (thanks!) # from http://www.bresink.de/osx/TemperatureMonitor.html # Needs to be installed in Applications/Utilities # HDD_TEMP=`/Applications/Utilities/TemperatureMonitor.app/Contents/MacOS/tempmonitor -c -l -a | grep "SMART Disk" | sed "s/.*: *//" | sed "s/ C$//"` # # Assume 40C is normal temperature. Anything over that is overheat # OVERHEAT=$(($HDD_TEMP - 40)) if [ "$OVERHEAT" -le 0 ]; then OVERHEAT=0; fi # # Scale the overheat to fan's RPM. Run 1000RPM at 40C, scale to 4000PRM at 70C # Disclaimer: set yourself whatever you think is safe and/or reasonable. No claims, please. # RPM=$((1000 + $OVERHEAT * 100)) RPM4HEX=`printf "%04x" $(($RPM * 4))` echo "TEMP=$HDD_TEMP OVERHEAT=$OVERHEAT RPM=$RPM RPM4HEX=$RPM4HEX" # # Set target PRM using smcFanControl by Hendrik Holtmann (thanks!) # e.g. from http://www.macupdate.com/app/mac/23049/smcfancontrol # Needs to be installed in Applications/Utilities # /Applications/Utilities/smcFanControl.app/Contents/Resources/smc -k F1Mx -w $RPM4HEX