How to disable the screen saver/display sleep on Mac

倾然丶 夕夏残阳落幕 提交于 2019-12-21 11:30:17

问题


Is there a way to disable the screen saver and the display sleep with cocoa?


回答1:


The use of UpdateSystemActivity(OverallAct) has been deprecated in OSX 10.8.

The recommended approach is now to block it with the following call:

IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep,
                            kIOPMAssertionLevelOn, reasonForActivity, &assertionID);

See this Apple Q&A for further details.




回答2:


i've just solved it and forgot to post it as an answer. Calling UpdateSystemActivity(OverallAct) every 30 seconds works.



来源:https://stackoverflow.com/questions/5126953/how-to-disable-the-screen-saver-display-sleep-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!