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.

jscs
  • 63,694
  • 13
  • 151
  • 195
Jake Chasan
  • 6,290
  • 9
  • 44
  • 90
  • This seems like a rather rude thing to do. Won't your users want to use their displays for something else? – zneak Sep 06 '13 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. – Jake Chasan Sep 07 '13 at 00:04

0 Answers0