Remove this ad
avatar

ericn

superstar

Posts: 284

Lead

Jun 28 10 10:49 PM

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. 


Quote    Reply   
Remove this ad
Remove this ad
avatar

ericn

superstar

Posts: 284

#1 [url]

Jun 30 10 6:53 PM

To acquaint everyone with the other things that fb-rotate can do, I'll walk though each of the options. 


After you've changed the current directory to the one fb-rotate is stored, then,


./fb-rotate -l


will list the display id's, e.g.


$ cd /Applications/Modbook\ Tools/fb-rotateNEW2 

$ ./fb-rotate -l

Display ID       Resolution

0x19156030       1280x800                  [main display]

0x76405c2d       1344x1008 



./fb-rotate -i


will list the display id's with other information, e.g.


$ ./fb-rotate -i

#  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:  (   528 ,   409 )


[Unlike the file com.apple.windowserver.plist, fb-rotate's information is always accurate and current.]



./fb-rotate -d 0 -r 180


will rotate the main display 180 degrees, e.g.


$ ./fb-rotate -d 0 -r 180

$ ./fb-rotate -i

#  Display_ID  Resolution  ____Display_Bounds____  Rotation

0  0x19156030  1280x800       0     0  1280   800    180    [main][internal]

1  0x76405c2d  1024x768    1280     0  2304   768      0    

Mouse Cursor Position:  (  1047 ,   359 )


[You can rotate to the 0, 90 and 270 degree orientations as well.]



./fb-rotate -d <display ID> -r 0


will rotate the display with the indicated ID back to the standard orientation, e.g.


$ ./fb-rotate -d 0x19156030 -r 0

$ ./fb-rotate -i

#  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:  (   226 ,   103 )


[Again, you can also rotate to the 90, 180 and 270 degree orientations.]



Finally, as noted earlier,


./fb-rotate -d <display ID> -m


will set the display with the indicated ID to be the primary (main) display that has the menu bar, e.g.


$ ./fb-rotate -d 0x76405c2d -m

$ ./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:  (  1122 ,   438 )


And that's all there is to it.


EricN

Quote    Reply   
avatar

ericn

superstar

Posts: 284

#2 [url]

Oct 15 10 11:28 AM


I just made the source for fb-rotate available in a code repository at Github. The older source versions of fb-rotate are the just the older "commits" at the repository. Older binary versions can be found at the MacFlip post

...



fb-rotate versions

Amit Singh's original version,
Source code: github-AmitSinghsOriginal
Download: fb-rotate.zip

Second version, more display info, but display rotation only,
Source code: github-RotateOnly
Download: fb-rotateNEW.zip

Current version that switches the primary display also,
Source code: github-master
Download: fb-rotateNEW2.zip

Quote    Reply   

#3 [url]

Jan 4 17 9:45 PM

Is there a way to flip the screen around the horizontal axis rather than rotate it? I've got an app that will mirror my screen to an iPad and want to use it in a teleprompter device (ergo why the screen needs to be a mirror image or flipped horizontal).

Quote    Reply   
Add Reply

Quick Reply

bbcode help