Skip to content

Instantly share code, notes, and snippets.

@aaronwolen
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronwolen/b3b9b18162ab2bb97793 to your computer and use it in GitHub Desktop.
Save aaronwolen/b3b9b18162ab2bb97793 to your computer and use it in GitHub Desktop.
Toggle fullscreen mode for OS X applications depending on display size
(*
display-specific fullscreen behavior
enable fullscreen for specific applications on MacBook and disable fullscreen
when using a larger external display
adapted from:
* https://gist.github.com/dsummersl/4175461
* http://daringfireball.net/2006/12/display_size_applescript_the_lazy_way
*)
-- display height of macbook where fullscreen should be enabled
set fsHeight to 800
-- fullscreen applications to toggle
set fsApps to {"Safari", "RStudio"}
tell application "Finder"
set displayBounds to bounds of window of desktop
set displayHeight to item 4 of displayBounds
end tell
if displayHeight is fsHeight then
set toggleOnFull to true
else
set toggleOnFull to false
end if
repeat with theApp in fsApps
if application theApp is running then
tell application theApp
activate
delay 1
set isfullscreen to false
tell application "System Events" to tell process theApp
set isfullscreen to value of attribute "AXFullScreen" of window 1
end tell
if isfullscreen is not toggleOnFull then
tell application "System Events" to keystroke "f" using {command down, control down}
delay 1
end if
end tell
end if
end repeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment