Skip to content

Instantly share code, notes, and snippets.

@twlz0ne
Last active August 22, 2023 12:42
Show Gist options
  • Save twlz0ne/4708084 to your computer and use it in GitHub Desktop.
Save twlz0ne/4708084 to your computer and use it in GitHub Desktop.
Rotate Display using AppleScript for MacOSX 10.6.8
tell application "System Preferences"
quit
delay 1
launch
activate
tell application "System Events"
key down {option, command}
end tell
reveal pane id "com.apple.preference.displays"
tell application "System Events"
key up {option, command}
tell process "System Preferences"
tell window "Color LCD"
click pop up button "Rotation:" of group 1 of tab group 1
keystroke "90" & return
set success to 0
repeat until success is equal to 1
delay 1
try
tell sheet 1
click button "Confirm"
set success to 1
end tell
on error errText
log errText
delay 1
end try
end repeat
end tell
end tell
end tell
end tell
tell application "System Preferences"
quit
delay 1
launch
activate
tell application "System Events"
key down {option, command}
end tell
reveal pane id "com.apple.preference.displays"
tell application "System Events"
key up {option, command}
tell process "System Preferences"
tell window "Color LCD"
click pop up button "Rotation:" of group 1 of tab group 1
keystroke "Standard" & return
-- If "Standard" is selected, no confirmation dialog is displayed.
end tell
end tell
end tell
end tell
@twlz0ne
Copy link
Author

twlz0ne commented Aug 22, 2023

Use https://github.com/CdLbB/fb-rotate instead.

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 )

Rotate screen with by d (display) and r (rotate) options:

fb-rotate -d 0 -r 180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment