Is it possible to detect Power Nap / DarkWake mode in OSX

孤街浪徒 提交于 2019-12-21 12:39:25

问题


I have a daemon process started via launchd. This will be running even during DarkWake and has no time to finish before OS X goes back to sleep again.

I can think of the following solutions, but didn't find a way to achieve this.

  1. Don't make this daemon process run during DarkWake.

    I went through Apple documentation and forums but didn't find any reference for this.

  2. During DarkWake via daemon process make the OS wait until its done.

    Tried with calling pmset noidle and caffeinate in daemon process. It didn't work. OS X went to sleep. It seems OS X suppresses the delivery of many notifications when in DarkWake mode.

  3. Detect DarkWake mode in daemon process.

    Didnt find any solution/method to detect DarkWake mode.

Please help.


回答1:


Just needed to find out about these wakes too. Using the log utility, I can see these lines when the system wakes up on its own (even without powernap activated):

2019-04-11 22:18:00.622600+0200 0x250 Default 0x0 83 0 powerd: [powerd:sleepWake] vm.darkwake_mode: 1 -> 1

2019-04-11 22:18:00.625413+0200 0x250 Default 0x0 83 0 powerd: [powerd:sleepWake] DarkWake from Deep Idle [CDN] due to RTC/Maintenance:

In order to detect this, something like this should work:

log show --last 1m --predicate 'subsystem == "powerd"' | grep "DarkWake from Deep Idle"

Alternatively, using caffeinate in your script might work too (haven't tested this yet).



来源:https://stackoverflow.com/questions/32227580/is-it-possible-to-detect-power-nap-darkwake-mode-in-osx

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