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.

  • 1
    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.

You must log in to answer this question.

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