Macos – Change Main Display via Keyboard Shortcut or command line in Mac OS X

keyboard shortcutsmacmacosmultiple-monitors

I am using OS X 10.11.3 (15D21) with one monitor and one projector.

Mirroring is turned off.

Mac OS X has an option to switch the main display (the display that has the upper menu) via the System Preferences, as depicted in the attached screenshot:attached screenshot

Basically to switch one drags the little menu bar from one side to the other.

My question is: Is there a way to accomplish this switch via the keyboard or better yet as a command from the Terminal?

Best Answer

hmscreens work great. Here's a sample command line to swap monitors:

hmscreens -setMainID `hmscreens -info | grep "Screen ID:" | head -2 | tail -1 | sed 's/[^0-9]*//g'`
Related Question