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

I have a daemon process running through launchd. This will work even during DarkWake and will not have time to complete before OS X goes into sleep mode again.

I can think of the following solutions, but have not found a way to achieve this.

  1. Do not start this daemon process during DarkWake.

    I went through the Apple documentation and forums, but found no link for this.

  2. During DarkWake, through the daemon process, make the OS wait until it is done.

    I tried calling pmset noidle and caffeine in the demon process. This did not work. OS X went to sleep. It seems that OS X suppresses the delivery of many notifications in DarkWake mode.

  3. Define DarkWake mode in the daemon process.

    I did not find any solution / method for detecting DarkWake mode.

Please help.

+5
source share
1 answer

I just needed to learn about these awakenings, too. Using the utility log, I see these lines when the system wakes up by itself (even without turning on powernap):

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 / service:

To detect this, something like this should work:

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

Alternatively, using caffeine in your script may also work (not yet verified).

0
source

All Articles