version 0.1
Requires Mac OS X 10.4 or higher

HAMSoft Engineering allows free use of this code and/or software in its "as is" condition. HAMSoft Engineering disclaims any liability of any kind for any damages whatsoever resulting from the use of this code and/or software. If you find it useful please consider making a donation to help HAMSoft Engineering stay in business.

download the compiled command line tool
download the source code project

Use this command line tool to either get information about your screens or to change/set the main screen (the screen with the menu bar).

Usage: hmscreens
[-h] shows the help text
[-info] shows information about the connected screens
[-screenIDs] returns only the screen IDs for the connected screens
[-setMainID "Screen ID"] Screen ID of the screen that you want to make the main screen
[-othersStartingPosition "position"] left, right, top, or bottom... with -setMainID, this determines placement of other screens

Get information about your screens
hmscreens -info

Make the screen with screen id 69670848 the main screen and position other screens around it starting on the left
hmscreens -setMainID 69670848 -othersStartingPosition left

NOTE: Global Position {0, 0} coordinate (as shown under -info) is the lower left corner of the main screen

Example usage of the tool with applescript:
Open this Script in your Editor

-- this will make your second screen the main screen

-- so in a 2 screen configuration, it will toggle the main screen between your 2 screens

set hms to (path to home folder as text) & "UnixBins:hmscreens"

set othersPosition to "left"

set screenIDs to paragraphs of (do shell script quoted form of POSIX path of hms & " -screenIDs")

if (count of screenIDs) is greater than 1 then

set secondScreen to item 2 of screenIDs

do shell script quoted form of POSIX path of hms & " -setMainID " & secondScreen & " -othersStartingPosition " & othersPosition


tell me


display dialog "Only one screen is attached to your computer!" buttons {"OK"} default button 1 with icon note

end tell

end if