In the most recent version of OSX Lion, how do you wake up the machine from display sleep? This is in response to network activity.
In 10.7.3 this was possible with the following call:
IOPMAssertionID id = 0; IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, reason, &id)
However, this does not work in 10.7.4. What can be done instead?
I have not yet tested the performance implications nor the interaction with the idle timer itself, but:
io_registry_entry_t regEntry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler"); if (regEntry != MACH_PORT_NULL) { IORegistryEntrySetCFProperty(regEntry, CFSTR("IORequestIdle"), kCFBooleanFalse); IOObjectRelease(regEntry); }
works in 10.7.4 to wake the screen from idle.
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
command line utility I suppose :)