Mac Sudden Motion Sensor: Obtaining activation state
Very similar to this SuperUser question, I'd like to know if there's a way to know when the SMS is actually engaged.
Note that I do not want to know if the sensor is enabled (which can be done from the Terminal with sudo pmset -g
). Specifically I want to know when the sensor trips and forces the hard drive's head to park, and when it senses the danger is clear and allows the head to move again. In an ideal case a Growl notification would be fantastic, but even a log would suffice.
I ask because as Apple notes on their support page, the SMS can be tripped in certain environments such as nightclubs when it would be undesirable. However the only way to know if you are in such an environment is by guessing since I haven't found a way to tell the frequency or length of time the SMS actually causes head parks. I understand the simple thing to do is disable the sensor outright, but the point of the question is how to gain visibility into the actual activity of the sensor.
Solution 1:
The Sudden Motion Sensor state is available through IOKit
.
An open source library, SMSLib, provides an Objective-C interface and sample command line tool for accessing the state of the Sudden Motion Sensor:
SMSLib is the software library used by SeisMac and SeisMaCalibrate to access the Sudden Motion Sensors in recent Macintosh laptops. Written in Objective-C, it provides easy and stable access, abstracting hardware differences across eleven different models of laptop. For better accuracy, you can use SeisMaCalibrate to calibrate your laptop's Sudden Motion Sensors. SMSLib is open source, released under the University of Illinois/NCSA Open Source License.
Additional sample code and tools are available on Amit Singh's Sudden Motion Sensor page.
A relevant technical question was asked on StackOverflow about this topic, Polling the accelerometer/motion sensor in a MacBook Pro.