Tags : :
“fb-rotate” is a nifty little Unix utility that I've been slowly improving and, in the process, using it to give some of my AppleScripts the ability to rotate displays, determine display arrangement, determine mouse cursor location and, now, the ability to change the primary display. The utility began as a bare-bones display rotation program from Amit Singh's OSX Internals, which I've added to as I've learned more about Objective-C and Cocoa.
On OSX, the primary, or main, display is the display with the menu bar. Ordinarily, you change the main display by dragging the menu bar box to a different display in System Preferences' Displays tab.

Using fb-rotate, you can now do this in Terminal. After downloading or compiling the utility and changing the working directory to fb-rotate's folder, changing the primary display works as follows:
$ ./fb-rotate -i # info on displays
# Display_ID Resolution ____Display_Bounds____ Rotation
0 0x19156030 1280x800 0 0 1280 800 0 [main][internal]
1 0x76405c2d 1344x1008 1280 0 2624 1008 0
Mouse Cursor Position: ( 32 , 464 )
$ ./fb-rotate -d 0x76405c2d -m # set main display to ‘0x76405c2d’
$ ./fb-rotate -i
# Display_ID Resolution ____Display_Bounds____ Rotation
1 0x76405c2d 1344x1008 0 0 1344 1008 0 [main]
0 0x19156030 1280x800 -1280 0 0 800 0 [internal]
Mouse Cursor Position: ( 32 , 464 )
[Note that the main display moved from ‘0x19156030’ to ‘0x76405c2d’.]
Download: fb-rotateNEW2.zip [Updated June 28, 2010]
This addition to fb-rotate should make it possible for the menu bar to follow the mouse between displays in my display switching AppleScript: SwitchTabletDisplay — a significant improvement. Stay tuned.