Programmatically wake display on OSX

后端 未结 2 627
野性不改
野性不改 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:54

    Here is the answer in Swift 3.x:

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

提交回复
热议问题