Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to change the primary screen for a Mac through command line?

The traditional way of doing this is from System Preferences > Displays and dragging the white menu bar on the top, between screens.

I have different setups at home and work and sometimes I need the primary display to be different. Rather than having to change this by dragging/dropping as explained above, I would like to run a script through a program like Alfred/QuickSilver and then just toggle/switch my primary displays.

If i could do this through command line, it would be awesome. There is this program called cscreen that allows me to do this, but it only runs on PowerMacs.

share|improve this question
If no one has an easy answer, you might need to run fs_usage and track which preference file changes to record the choice of screen to host the menu bar. Once you've captured a version of that file for each layout, you could easily script that as a shell script. Also, try comparing the files in case it's just a trivial edit and the preference isn't somehow embedded in a data structure or otherwise not easily editable by a shell script. – bmike Dec 18 '12 at 20:29

cscreen actually runs on Intel-based Mac as well. You should be able to change primary display through it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.