8

I have a MacBook Pro and two Thunderbolt displays at work. I work with the MacBook lid-closed because it's overkill and I don't have enough desk space anyway.

Every morning I show up to work and plug in a Thunderbolt cable and power cord, but my primary screen (the one in front) and secondary (one off to the side) are swapped. I have to this stupid song and dance in the Displays / Arrangement system preference and it's getting annoying:

enter image description here enter image description here

Is there a way to do this automatically? With a setting? An AppleScript? Is there a reason that the screens are always flipped?

3

Update: I think I got it.

There's a utility called cscreen which lets you control the display settings. Running it shows all displays:

$ cscreen
DisplayID  Index     Depth     Width     Height  Refresh
 4249fef       1        32      2560       1440     0
 4248344       2        32      2560       1440     0
use -h to display all usage options

Sure enough, you can force one of them to be primary (with menu bar):

$ cscreen -i 4248344 -p

You can script setting the second screen as the primary like this:

$ cscreen -l | perl -lane 'print $F[0] if $F[1] == 2' | xargs -I id cscreen -i id -p

Now, to bind to a key, I first created an AppleScript script, SwapScreen.scpt:

swapscreen

Then I used QuickSilver to bind the script to a F13:

quicksilver

Now, when I plug in my MacBook, if the screens are messed up, I simply hit F13. Sweet!

  • 1
    But using cscreen doesn't solve the arrangement problem for me. My 23" monitor is on the left, and my 13"MBP on the right. However, using cscreen, will reverse that, so I have to move the cursor the opposite direction to move from one display to the other. Even when switching back (ie.using cscreen to toggle) the arrangement is reversed. What's needed is a way to programmatically fix the arrangement in the same way as when you drag one to the left/right of the other. Setting the arrangement in the root user as suggested by DKMN here did not work in my case. – applehelpwriter Jan 30 '14 at 14:12
  • Agreed, would be nice if the author (pyehouse) open sourced cscreen so others could enhance it. – studgeek Dec 2 '15 at 19:15
2

Been there, done that, with Mac Pro and 4 monitors. ;0

There is an odd bug/feature in OSX that makes default display settings privileged. This behavior has not changed with 10.9 and I believe is what is causing your problem. It is very poorly-documented and discussed on the web.

A permanent solution:

  1. Log on as the root user (you will have to temporarily enable it).

  2. Set the Display arrangement to what you want (as you show above)

  3. Log back on as whatever you like

It is somewhat non-obvious how to enable the Root User for interactive login, though not hard. Here is the official Apple guide:

http://support.apple.com/kb/PH113311

I would disable it when done for security reasons.

  • BTW I also worked around this with a small app for a while... – DKMN Nov 17 '13 at 22:12
  • Any chance you could share said app, please? – BarrettJ Dec 16 '13 at 1:16
1

It should remember the external setttings.

Did you try to swap the cables behind the monitor in order to invert the connection order? Maybe could do the trick.

A very easy solution is waiting one months and upgrade to OS X Mavericks, where you will have the possibility of having the menu bar and dock on both screen

  • Yes, displays have been swapped repeatedly. I have hesitation toward upgrading to a dot-zero revision of Mac OS X, though. – a paid nerd Sep 23 '13 at 23:11
1

The tool I wrote, displayplacer, allows you to configure the "white bar" main display via scripts/hotkeys.

Configure your screens how you like, drag the "white bar" to your primary screen in the macOS system settings, and then execute displayplacer list. It will output the command to run to put your screens in their current configuration. The screen with origin:(0,0) is the main display with the "white bar". Run this terminal command through a script, Automator, BetterTouchTool, etc.

Example profile 1 puts the white bar on the menu bar on the left monitor. displayplacer "id:<leftScreenId> res:1920x1080 scaling:on origin:(0,0) degree:0" "id:<rightScreenId> res:1920x1080 scaling:on origin:(1920,0) degree:0"

Example profile 1 puts the white bar on the menu bar on the right monitor. displayplacer "id:<leftScreenId> res:1920x1080 scaling:on origin:(1920,0) degree:0" "id:<rightScreenId> res:1920x1080 scaling:on origin:(0,0) degree:0"

Also available via Homebrew brew tap jakehilborn/jakehilborn && brew install displayplacer

0

cscreen doesn't work properly when you have more than 2 monitors, and even if it did, switching primary monitors with it will mess up the positions of your desktop icons.

The best solution I know is a utility called SwitchResX (http://www.madrau.com/). It has a feature called Display Sets that effectively remembers everything about a particular display setup (including resolution, orientation, and which screen is primary). You can then switch to a specific Set from the menu bar or with a shortcut. It remembers the positions of your desktop icons when you switch to a different Set, and puts them back when you restore.

Works like a charm, and there's no need for AppleScript. SwitchResX is also great at its primary function: easily changing screen resolution, even to resolutions not normally available in System Preferences. It's essential if you do a lot of presenting and have to switch res to whatever projector setup you're stuck with.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .