It appears from the docs that the way to "wake up" the display these days is:
IOPMAssertionID assertionID2;
IOPMAssertionDeclareUserActivity(CFSTR("Your reasoning"),
kIOPMUserActiveLocal, &assertionID2);
The IOPMAssertionCreateWithName(...)
way from original the question only "prevents display going to sleep" if it's already on (though it does work and can also be used to prevent it from going to sleep for a duration of time).
The way the docs method for "keeping" the display on works about the same way as IOPMAssertionCreateWithName
IOPMAssertionID m_disableDisplaySleepAssertion;
IOReturn success2 = IOPMAssertionCreateWithDescription(
kIOPMAssertionTypePreventUserIdleDisplaySleep, reasonForActivity, NULL, NULL, NULL, 0, NULL, &m_disableDisplaySleepAssertion);
if (success2 == kIOReturnSuccess) {
// screen will stay on, do you work
success = IOPMAssertionRelease(m_disableDisplaySleepAssertion);
}
If you want to "turn it on and keep it on forever" then IOPMAssertionDeclareUserActivity
followed by the above, or just call IOPMAssertionDeclareUserActivity
over and over again somehow.
You could also call out to the caffeinate
built-in command line utility I suppose :)