Program View in OSX

I was able to immediately display the display with

pmset displaysleepnow

in the terminal, however, to wake up the display, I found only

pmset schedule wake "12/24/2009 00:00:00" 

which does not work if I try to plan something earlier than at least 10 seconds.

Is there a way to wake up the display programmatically in Cocoa? Someone suggested IOPMAssertionDeclareUserActivity, but I could not find any examples, so I'm afraid.

I use Swift, by the way, but Objective-C code is also welcome.

Thank!

+4
source share
2 answers

With his help:

  IOPMAssertionID assertionID; 
  IOPMAssertionDeclareUserActivity(CFSTR(""), kIOPMUserActiveLocal, &assertionID);
+6
source

Here is the answer in Swift 3.x:

var assertionID : IOPMAssertionID = 0 _ = IOPMAssertionDeclareUserActivity("" as CFString, kIOPMUserActiveLocal, &assertionID)

+1
source

All Articles