0

I am trying to only have secondary monitors turn off. I have seen this code:

#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>

/* Returns 0 on success and 1 on failure. */
int display_sleep(void)
{
    io_registry_entry_t reg = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
    if (reg) {
                IORegistryEntrySetCFProperty(reg, CFSTR("IORequestIdle"), kCFBooleanTrue);
                IOObjectRelease(reg);
        } else {
                return 1;
        }
        return 0;
}

However, it appears as through the code will put all monitors asleep.

Does anyone have any ideas on how to put only the secondary monitors to sleep?

Thanks.

2
  • This seems like a rather rude thing to do. Won't your users want to use their displays for something else?
    – zneak
    Sep 6, 2013 at 23:58
  • It is to save power and heat. When a display is on, it can get very hot, and when not in use, this code will be used to power down the display and only keep the main display active. Sep 7, 2013 at 0:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.