How to wake from sleep programmatically if lid closed?

前端 未结 1 797
挽巷
挽巷 2020-12-01 07:02

I want to wake system from sleep programmatically, is there any way to do this?

I have read following link: http://developer.apple.com/mac/library/qa/qa2004/qa1340.h

相关标签:
1条回答
  • 2020-12-01 07:33

    You can schedule wake up events with IOPMSchedulePowerEvent through the power manager. You may be able to schedule an immediate wake up. pmset is a command line wrapper for the power manager. You can also prevent sleep with IOCancelPowerChange in certain cases.

    You may be able to prevent sleep or wake up by generating a mouse or key event. One way to generate events is with CGPostKeyboardEvent.

    Edit:

    Normal sleep is different from clamshell closed sleep. To affect the latter you must write a kernel extension like Insomnia.

    0 讨论(0)
提交回复
热议问题