I\'ve managed to get the display to sleep immediately with
pmset displaysleepnow
in terminal, however for waking the display I\'ve only found
Got it working with:
IOPMAssertionID assertionID;
IOPMAssertionDeclareUserActivity(CFSTR(""), kIOPMUserActiveLocal, &assertionID);
Here is the answer in Swift 3.x:
var assertionID : IOPMAssertionID = 0
_ = IOPMAssertionDeclareUserActivity("" as CFString, kIOPMUserActiveLocal, &assertionID)