How to control the fan speed of your mac

Time to revive the blog! This first project has nothing at all to do with security, but I guess it is a bit of a hack =].

The purpose of this project was to originally fix the jet engine I created when I upgraded the hard drive in my late 2009 mac mini. The late 2009 model in particular has a hard drive thermal sensor that is completely dependent on the internal sensor of the drive that comes with the computer, and if you replace the drive the fan starts spinning at 6000 RPM nonstop.

I have also confirmed this fix works with macbook pros and airs of the same era, I can’t imagine it wouldn’t work with any mac tho.

Difficulty: Moderate
Technologies used: Automator, Terminal (including text editor)

Articles exist elsewhere that tell you how to do this in pieces so I can’t take credit for most of it, but here’s a compilation.

Step 1:
Install smcfancontrol: http://www.eidac.de/

Step 2:
Open up automator, create a new application.
On the left, select “Utilities” and double click “Run Shell Script”
Paste this line of code in the box:

/Applications/smcFanControl.app/Contents/Resources/smc –k F0MX –w Zee0

After the ‘–w’ is the hex code for 3000. For whatever reason, for this to work you take the RPM you want, multiply it by 4, and go here to convert it :
http://www.binaryhexconverter.com/hex-to-decimal-converter

So for example, to get 3000 RPM, I put 12000 in the decimal value and that gave me “Zee0”. In my testing I found anything 4000 RPM or below is tolerable, but I just use my mini as a mediaserver and 3000 RPM is plenty for me.

Lastly, save it as something, ideally in your applications folder (i called mine fan_control).

Step 3:
Create a script to fire up your automator program (i use nano for this from terminal):

#! /bin/bash
open “/Applications/fan_control.app”

save it as “~/.wakeup” (this is the default location that sleepwatcher looks for sleep/wakeup scripts, you can also modify sleepwatcher to default to a different location if you want)

Make it executable:

Chmod 700 ~/.wakeup

Download sleepwatcher (you have some options here, I recommend brew. If you don’t already have it, from a terminal run:)

sudo ruby -e "$(curl –fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install sleepwatcher from terminal:

sudo brew install sleepwatcher

You can also just browse to the site and download the tarball:

http://www.bernhard-baehr.de/

Step 4:
Test out sleepwatcher, make sure it will do what you want. Run this:

/path/to/sleepwatcher –-verbose –-wakeup ~/.wakeup

Now put your machine to sleep and wake it back up. Don’t hear the deafening fan noise anymore? Your script is working! (hallelujah!)

Step 5:

Now that sleepwatcher is working, you need it to run in the background. Since I have multiple accounts on my mini and I want it to run all the time, I elected to install it as a system agent (you need admin rights to do this)

From terminal:
sudo ln -sfv /usr/local/Cellar/sleepwatcher/2.2/de.bernhard-baehr.sleepwatcher-20compatibility.plist /Library/LaunchAgents/
sudo launchctl /Library/LaunchAgents/de.bernhard-baehr.sleepwatcher-20compatibility.plist

That’s it! Welcome back to peace and quiet.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>