4 years ago

Exchanging primary / secondary display in OSX with a shortcut

Category: Webdev

If you have to attach external displays and projectors on a regular basis (or switching workspace environments a couple of times a day) you might have searched for a way to exchange primary and secondary display in OSX with a shortcut as well - the official way is to drag and drop the menu bar in the system preferences each time, quite a hassle:

Fussing around with the Display System Preferences

Still working with Retina Displays

I am using a Retina display now but the latest published version of the handy command line tool cscreen still works perfectly and flawless.

You can create a little app with Automator and then call it with Alfred.app or Quicksilver (and/or Marco Polo) to switch your display order just with the hit of a shortcut - very handy :)


The documentation for the tool can be listened with the command

./cscreen -h

and will give you:

Usage: cscreen [-d ] [-x ] [-y ] [-r ] [-s ] [-v] [-m] [-f] [-l] [-h]
           [-d ]    : specifies the bit depth (bits per pixel)
           [-x ]    : specifies the width in pixels
           [-y ]   : specifies the height in pixels
           [-r ]  : specifies the refresh rate in Hz
           [-s ]  : specifies which display to use (defaults to main display)
           use a as the option to -s to specify the action on all displays
           [-i ]: picks a display based on CGDirectDisplayID (permanent per display)
           continue to use '-s a' for "all displays"
           [-v]            : display valid modes (use -s to specify display or nothing for the default)
           [-m]            : require an exact match
           [-f]            : forces settings (ignores safety mechanisms; USE AT YOUR OWN RISK)
           [-l]            : lists the current displays and modes
           [-p]            : sets the requested display to have the menu bar
           [-h]            : displays the usage

           Note: Using -p will change the display index so you will likely want to use -l again to show the current
           displays if you wish to use -p a second time.

Update: I am still on 10.9, I was told the whole situation has gotten better with 10.10..

P.s.: I wrote about this on my private blog a couple of years ago - there are some helpful comments there as well.

  • This article is my 7th oldest. It is 371 words long.