Programmatically disable individual monitor

Is there an API or way to programmatically disable a separate external monitor via Objective-C on a Mac?

I want to write a small menu that can control an additional display (without a physical power button), but at the same time keep the main monitor.

Hunting for API documentation, I can find nothing but read status. So hoping that someone else might have an idea.

+8
objective-c cocoa macos
source share
2 answers

It seems like you can sleep with the display, so the I / O Kit :

But I'm not sure if it can control individual monitors.

+2
source share

You cannot “disable a separate monitor programmatically”; this is physically impossible. Most of all you can say that the OS does not use a monitor, but I do not think that you can change system-wide settings like this, especially at the level at which you work (Obj-C).

Take a look at the Core Graphics API mentioned in the @Halley comment, try starting with the CGBeginDisplayConfiguration method and see if you can set the display to your liking.

EDIT: Alternatively, you can also use CGDisplayCapture (displayID) , which by default fills the captured screen with black. Then you can call CGDisplayRelease (displayID) if you want to enable it again.

+1
source share

All Articles