Programmatically wake display on OSX

后端 未结 2 625
野性不改
野性不改 2021-02-10 04:30

I\'ve managed to get the display to sleep immediately with

pmset displaysleepnow

in terminal, however for waking the display I\'ve only found

相关标签:
2条回答
  • 2021-02-10 04:48

    Got it working with:

      IOPMAssertionID assertionID; 
      IOPMAssertionDeclareUserActivity(CFSTR(""), kIOPMUserActiveLocal, &assertionID);
    
    0 讨论(0)
  • 2021-02-10 04:54

    Here is the answer in Swift 3.x:

    var assertionID : IOPMAssertionID = 0
     _ = IOPMAssertionDeclareUserActivity("" as CFString, kIOPMUserActiveLocal, &assertionID)
    
    0 讨论(0)
提交回复
热议问题