Sleep Secondary Display Mac

285 views Asked by At

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.

0

There are 0 answers