Search code examples
macosmonitor

Change main monitor on Mac programmatically


I would like to disable the primary monitor on a Mac and then change secondary monitor to be the main programmatically. Any help on how I can do this? Not sure where to start my research.


Solution

  • To change the secondary monitor to be the main screen is quite straightforward. One need to set the origin 0,0 to the secondary display using CGConfigureDisplayOrigin().

    A full sample can be found Here

    To the question how to disable the monitor, unfortunately I have no answer.I am trying to figure out how it can be done because there are some applications like SwitchResX that are able to disable displays, so somehow it must be possible.