开发者

Prevent Shutdown/Sleep on Macs

开发者 https://www.devze.com 2023-02-17 04:51 出处:网络
I need to be able to implement methods to prevent these from happening: Shutdown Restart Logoff Sleep On a Mac, I am using Xcode but can\'t seem to figure out the code to perform these actions.

I need to be able to implement methods to prevent these from happening:

  • Shutdown
  • Restart
  • Logoff
  • Sleep

On a Mac, I am using Xcode but can't seem to figure out the code to perform these actions.

开发者_如何学运维Can anyone help me out here?

I found this : http://developer.apple.com/library/mac/#qa/qa1134/_index.html

but I can't seem to understand how to block the system events when they are triggered.

Thanks


In Carbon's Application Manager, there's the SetSystemUIMode API which lets you control (disable) things like force-quit, the power-key window etc. It's intended for kiosk style applications and described in this tech note.

Disabling sleep, screen-saver, etc. is done by periodically calling UpdateSystemActivity. See this tech Q&A.


The simple and most effective way to prevent Apple OSX to sleep is the Terminal command:

   $ pmset noidle
   Preventing idle sleep (^C to exit)...

The only annoying thing maybe the user self has to end this manually by issuing a 'Control-C'.

0

精彩评论

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