Script to relocate the menu-bar on dual monitors set-up

displaymenu barscript

Is there a script that could be written to achieve this:
In System Preferences/Displays… is it possible to relocate the menu bar …via a script?
My set-up is one monitor and a Cintiq. I either work only with the Cintiq, or I work with my 28" monitor several times a day. I always need to go to do this manually.
I really wish there was a script that can do this. I tried Automator, but it's not recording the action. 🙁

Best Answer

You can use a command line utility named cscreen to do that. You can wrap it in a AppleSctipt script or in Automator. You can download the cscreenIntel.dmg from the link provided. In a terminal use cscreen -h to output the internal help information.

I have a MBP and a Thunderbolt Display so in a Terminal I want to have cscreen list my displays

$ cscreen -l
DisplayID  Index     Depth     Width     Height  Refresh
5ac6fa7f       1        32      1440        900     0
 3247b0f       2        32      2560       1440     0
use -h to display all usage options
$

So to set the Thunderbolt Display to have the menu bar I run the following command:

cscreen -s 2 -p

I can then toggle it back using the same command as the Index shifts.

In AppleScript: do shell script "/<path_to>/cscreen -s 2 -p"

In Automator add Run Shell Script and add command: /<path_to>/cscreen -s 2 -p

Note: This is a simple toggle if you only have two displays however if you have more then two you'll need to write some logic flow into the script.

You can also use, cscreen -i <DisplayID> -p, e.g. cscreen -i 3247b0f -p to code with the DisplayID which doesn't change.

This can also just be used in a Terminal as a singular command or incorporated into a shell script without using AppleScript and or Automator.