複数ディスプレイの時にプライマリを入れ替える

複数台のディスプレイを使っている時に、ソフトウェア側ではあってるんだけど、ハードウェア側の順番が入れ替わっている問題があって、それの解決策を探してました。


で、multiple display, dual display, dual monitor, multiple monitor, external display, external monitorとかの表記揺れに苦しんだ結果、下記のライブラリを発見。
やっぱりIOKit最強なのね。
AppleScriptではモニタの固有IDとれなかった。
http://modbookish.lefora.com/2010/06/29/a-unix-utility-to-change-the-primary-display-on-os/



$ ./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 )