2

I save the following AppleScript as application, to open Firefox in full screen and without the menu bar:

tell application "Firefox" to activate
delay 0.8
do shell script "lsappinfo setinfo -app Firefox ApplicationType=UIElement"
tell application "System Events" to tell process "Firefox" to set value of attribute "AXFullScreen" of last window to true

And execute it as:

open -a "Firefox Full Screen"

This works as expected, Firefox is opened, goes full screen, without the menu bar. The problem is when I try to call open with a URL:

open -a "Firefox Full Screen" "https://google.com"

This still opens Firefox, with the given URL in a new tab, but it doesn't execute the lines after delay 0.8, so it doesn't open in full screen. I don't understand why this happens and how to fix it.

I know those lines are not executed because the system doesn't warn that I need to add the application as an accessibility exception (when I don't have one added/enabled). It always warns if I don't pass the URL (and don't have an exception added/enabled).

EDIT 1

I also tried to execute the following version with open -a "Firefox Full Screen", open -a "Firefox Full Screen" "https://google.com", open -a "Firefox Full Screen" --args "https://google.com" and it's worse given that it doesn't execute the last lines in any case:

on run argv
    tell application "Firefox"
        activate
        repeat with arg in argv
            open location (arg as text)
        end repeat
    end tell
    delay 0.8
    do shell script "lsappinfo setinfo -app Firefox ApplicationType=UIElement"
    tell application "System Events" to tell process "Firefox" to set value of attribute "AXFullScreen" of last window to true
end run

EDIT 2

It seems the problem is related with https://stackoverflow.com/questions/14419700.

  • Leaving this as a comment rather than an answer because I can't test this right now. However, my feeling is that you might resolve the problem by enclosing your code in an on run argv...end run handler. That way, the URL(s) will pass to the AppleScript in the argv array, and you can use a repeat with arg in argv loop to open location (arg as text) in order to open the tabs that way after (hopefully) the rest of the script has excuted. – CJK Jan 22 '18 at 4:35
  • @CJK, I've tried that, but without a loop, just on run argv \n tell application "Firefox" \n activate \n if (count of argv) > 0 then open item 1 of argv \n end tell \n end run. It didn't work. – pepper_chico Jan 22 '18 at 4:41
  • Read the man page for the open comand: "--args All remaining arguments are passed to the opened application in the argv parameter to main(). These arguments are not opened or interpreted by the open tool." So it should be open -a "Firefox Full Screen" --args "https://google.com" - Also do as suggested by CJK in his comment. – user3439894 Jan 22 '18 at 4:42
  • @user3439894 Also tried that, didn't work. – pepper_chico Jan 22 '18 at 4:43
  • 1
    You should have included all of that in your question! – user3439894 Jan 22 '18 at 4:44
3

It looks like passing arguments to an AppleScript saved as an application has become broken at some point. I accomplished my task by using Automator to create an equivalent new Application that makes use of an Action > Utilities > Run Shell Script:

open -a Firefox
sleep 1
lsappinfo setinfo -app Firefox ApplicationType=UIElement
osascript -e 'tell application "System Events" to tell process "Firefox" to set value of attribute "AXFullScreen" of first window to true'
sleep 0.5
for f in "$@"; do open -a Firefox "$f"; done

I set the shell script Shell: to /bin/sh and Pass input: to as arguments, save it as "Firefox Full Screen" in /Applications, change its icon as explained here and add it as an exception in System Preferences > Security & Privacy > Privacy Tab > Accessibility.

I then can run any of the following and it works as expected:

  • open -a "Firefox Full Screen"
  • open -a "Firefox Full Screen" --args "https://google.com"
  • open -a "Firefox Full Screen" --args "https://google.com" "https://twitter.com"

I'm using this coupled with the following userChrome.css to both evade a well known issue with the macOS menu bar on full screen applications and another long standing address bar and tab auto-hide bug that Firefox have with macOS native full screen.

userChrome.css

#navigator-toolbox[inFullscreen] {
    position: relative;
    z-index: 1;
    height: 3px;
    margin-bottom: -3px;
    opacity: 0;
    overflow: hidden;
}

#navigator-toolbox[inFullscreen]:hover {
    height: auto;
    margin-bottom: 0px;
    opacity: 1;
    overflow: show;
}

#content-deck[inFullscreen]{
    position:relative;
    z-index: 0;
}

For a generic approach, check my other answer.

TIP

  • Firefox, by default, does not have any issue on Linux or Windows to auto-hide address bar and tabs in full screen as expected. With that said, I grabbed this userChrome.css from my ArchLinux setup. I use it on i3 and sway tiling window managers, with all the [inFullscreen] removed, to get address bar and tabs to auto-hide in normal bordless windows.
  • If you've answered your own question you should mark it as the accepted answer. – ʀ2ᴅ2 Jan 27 '18 at 3:41
  • @DᴀʀᴛʜVᴀᴅᴇʀ I'm just not doing it because, while it's a useful solution to the problem, I don't consider it an actual answer to the question. If someone knows how to pass arguments using AppleScript rather than shell script or that it's in fact impossible and why, I'd accept it. – pepper_chico Jan 27 '18 at 4:13
  • if I have time over the weekend I'll look at it and see if I can find a solution. – ʀ2ᴅ2 Jan 27 '18 at 4:14

You must log in to answer this question.

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