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

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

Have you looked at the IOPMAssertion API?

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Initiall i refrerred IOPMAssertion. But while going through it i got this. So didnt tried that.

"OSX also suppresses the delivery of many notifications when in DarkWake mode, including sleep/wake and network reachability"

I went through the source code of pmset. It seems even pmset internally uses IOPMAssertion itself?. Anyways i had verified with pmset noidle, its not working.

I’m out of suggestions here. If no one else chimes in, I recommend you open a DTS tech support incident and I, or one of my colleagues, can help you in a more formal context.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

You probably want to assert kIOPMAssertionTypePreventSystemSleep while you're finishing up so you don't get put to sleep:


When asserted and set to level kIOPMAssertionLevelOn, the system will prefer to enter the Dark Wake state, or remain in Dark Wake if already there, rather than go to sleep.


(See IOPMLib.h)

Is it possible to detect Power nap / DarkWake mode in OSX
 
 
Q