tags:

views:

83

answers:

3

Hey, I need to write a program for OSX that will cause my macbook pro to wake up after a certain amount of time of sleeping. SleepX is almost perfect for me, but I want it to only go back to sleep if noone is moving the mouse/hitting the keyboard, etc.... I tried using the approach in the "wakeFromSleep" example in the Mac power management DDK, but it was unable to find the "Power Management Unit" in my computer, so obviously SleepX is using a different method than the DDK.

Does anyone have any ideas on where I can look to find this API that SleepX is using? Does anyone have suggestions on what software I could use to achieve the end result?

Thank you!

+1  A: 

One place to start looking is

nm /Developer/Applications/Utilities/SleepX.app/Contents/MacOS/SleepX

the following lines look relevant

     U _IOAllowPowerChange
     U _IONotificationPortGetRunLoopSource
     U _IOPMSchedulePowerEvent
     U _IORegisterForSystemPower

which in turn come from IOPMLib.h

cobbal
Thanks cobbal, that is just what I was looking for!
staticfloat
+1  A: 

The pmset command makes it easy to schedule wakeups:

pmset schedule wake "07/04/09 20:00:00"
Ned Deily
A: 

You want IOPMSchedulePowerEvent.

Azeem.Butt
Thanks for the tip, NSD. Your comment combined with cobbal's answers my question!
staticfloat