I wonder if it's possible to open a program in Lion fullscreen mode via the Terminal. I want to write a short script which starts a bunch of programs in fullscreen mode, so that I only have to click once to start my working environment.

  • Is this the Lion / MTN Lion Full Screen Mode, or a window "zoomed"? – MrDaniel Aug 1 '12 at 12:58
  • the lion fullscreen – ABLX Aug 1 '12 at 14:10

Here it is:

/usr/bin/osascript -e 'tell application "Safari"' -e "activate" -e 'tell application "System Events"' -e 'keystroke "f" using {control down, command down}' -e "end tell" -e "end tell"

Here it is in a clearer form (but you can't run it this way):

/usr/bin/osascript -e "tell application \"Safari\"" 
-e "activate"
-e "tell application \"System Events\""
-e "keystroke \"f\" using {control down, command down}"
-e "end tell"
-e "end tell"

And this is it as formatted AppleScript:

tell application "Safari"
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
end tell

It works by first opening a Safari window if one is not currently open. Then it simulates the Control ⌃-Command ⌘-F keystroke which tells the Safari window to become full screen.

If you want to make the window the max-size it can be without becoming full screen (i.e. taking up all the space below the menu bar at the top):

tell application "Finder"
    set desktopSize to bounds of window of desktop
end tell

tell application "Safari"
    set bounds of window 1 to desktopSize
end tell

Which would become this in Terminal:

/usr/bin/osascript -e "tell application \"Finder\"" -e "set desktopSize to bounds of window of desktop" -e "end tell" -e "tell application \"Safari\"" -e "activate" -e "set bounds of window 1 to desktopSize" -e "end tell"

For Chrome, do this:

tell application "Google Chrome"
    make new window
    tell application "System Events"
        keystroke "f" using {control down, command down}
    end tell
end tell

So it would be this in Terminal:

/usr/bin/osascript -e "tell application \"Google Chrome\"" -e "activate" -e "make new window" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"

Hope this helps!

  • tryed this, and it helped a bit. it opens the app, but the fullscreen won't work - jsut gives me an error sound. have to run the script twice to go to fullscreen – ABLX Aug 1 '12 at 20:09
  • @ABLX You need to change the keystroke for whatever app you want to fullscreen - what apps are you working with? – CajunLuke Aug 1 '12 at 20:11
  • @qegal I believe entire screen - he mentioned Lion fullscreen in the question comments. – CajunLuke Aug 1 '12 at 20:12
  • evernote and chrome. it should be lion fullscreen – ABLX Aug 1 '12 at 20:13
  • aww my fault. evernotes want ^ + command + f. – ABLX Aug 1 '12 at 20:16

This won't work with applications that don't use native full screen windows, but should work with some that don't use the standard shortcut for entering full screen. A few applications have different process names and application names.

set a to "Notes"
set bid to id of application a
tell application a
    reopen -- open a new default window if there are no windows
    activate -- make frontmost
end tell
tell application "System Events" to tell (process 1 where bundle identifier is bid)
    click (button 1 of window 1 where subrole is "AXFullScreenButton")
end tell
  • This solution was effective to force Polycom RealPresence Desktop on full screen at login on an OS X 10.10.5 system, thanks ! – PEM8000 Dec 18 '15 at 15:26

Here's instructions for Google Chrome. (This will open an Incognito window to full-screen.)

Go to /Applications/Google Chrome.app/Content/MacOS/. Rename the Google Chrome binary to something else (like chrome-bin) and create an executable bash script in its place (name the script Google Chrome just like the original executable file).

open chrome-bin --new --args -incognito

osascript -e "tell application \"Google Chrome\"" -e "tell application \"System Events\"" -e "keystroke \"f\" using {control down, command down}" -e "end tell" -e "end tell"

Now, every time you launch Google Chrome it will launch full screen in Incognito mode. I use Incognito mode, but if you don't want that, just delete the -incognito flag.

  • 1
    The OP doesn't mention anything about Google Chrome. – CajunLuke Sep 17 '12 at 21:58
  • 1
    Also, Incognito mode won't help one whit when it comes to malicious code - it just doesn't store or allow access to cookies and other local (browser-controlled) persistence schemes. In fact, plugins (like Flash) can store and access their own cookies even in Incognito mode. – CajunLuke Sep 17 '12 at 22:09
  • +1 for the nice hack even if Chrome was not asked for in the question – myhd Sep 26 '12 at 10:32

Here's an addition to @pasawaya's excellent answer. If you want to execute your applescript from the command line, you don't need to enter every line separately with the -e option.

osascript -e 'multi-line-applescript here' will work also. Example:

osascript -e 'tell application "Safari"
  tell application "System Events"
    keystroke "f" using {control down, command down}
  end tell
end tell'

you can use browse to open arbitrary apps in full-screen mode.. It installs six convenience commands, four of which open the most common browsers in full-screen:

Launch Chrome Canary in Presentation Mode:

$ ca

Launch Chrome in Presentation Mode:

$ ch

Launch Firefox in full-screen Mode:

$ ff

Launch Safari in full-screen Mode:

$ sf

To launch anything in full-screen, run the command ccf (an applescript sending the CMD+CTRL+f keystroke) after a regular open to switch it to full-screen mode:

$ open -a Calendar; ccf

Should an app have an additional full-screen mode shortcutted by CMD+Shift+f (as Chrome does), use:

$ open -a "Google Chrome"; csf

Tip. If an app is slow to load, give it chance to load fully by inserting a pause before running the keyboard shortcut:

$ open -a "Google Chrome"; sleep 3; csf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .