Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 616
user12345 Avatar asked Aug 26 '15 13:08

user12345


1 Answers

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).

like image 78
kjyv Avatar answered Oct 26 '22 23:10

kjyv