开发者

How to determine why system wakeup occurred

Is it possible to determine the cause of system wakeup from sleep in OS X from Cocoa, a lower-level API method, or a terminal command (less preferable)? Possible reasons for wakeup include:

  • A keyboard button was pressed
  • The laptop lid was opened
  • Network activity was detected
  • A schedul开发者_StackOverflowed wakeup time (set with IOPMSchedulePowerEvent) occurred

I am trying in particular to detect the last reason, so that I can put the system to sleep for 10 minutes and then automatically into hibernation (aka safe sleep). To do so, I am scheduling a wakeup 10 minutes out, followed by a hibernate event. But I don't want to accidentally hibernate the system if the user activated a wakeup at roughly the same time.

FYI, this is apparently possible in Windows 7.


The terminal commands pmset -g log and pmset -g rawlog should help do what you need.

The manual for pmset documents these options; note the manual page shipped with Mac OS X 10.7 lists many more options.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜