Mac: Turn applications to Full Screen mode from bash

Posted . Visible to the public.

I needed a way to make my apps full screen from bash scripts. There is no super-easy way, but it's not too hard either.

Put the attached script into e.g. /usr/local/bin and make it executable. Now you can call

fullscreen Safari

and Safari will go full screen.

Notes

  • This script needs activated access for assisting devices. Turn it on with osascript -e 'tell application "System Events" to set UI elements enabled to true'.
  • The capitalization of the application name is important, i.e. it's TextMate and not textmate.
  • The script attempts to fullscreenize the frontmost window of the application.
  • Fullscreenization apparently only works with apps (and windows) that support it.

Toggle

You also may use the script to exit or toggle Full Screen. Just edit the script according to the comments.

Dominik Schöler
Last edit
Attachments
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2013-01-08 07:51)