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.
on run argv...end run
handler. That way, the URL(s) will pass to the AppleScript in theargv
array, and you can use arepeat with arg in argv
loop toopen 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 04:35on 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. – oblitum Jan 22 '18 at 04:41open
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 beopen -a "Firefox Full Screen" --args "https://google.com"
- Also do as suggested by CJK in his comment. – user3439894 Jan 22 '18 at 04:42--args
, usingon run argv
, etc. – oblitum Jan 22 '18 at 04:44open item 1 of argv
is the wrong command if you’re running recent versions of Firefox and MacOS. Useopen location
. – CJK Jan 22 '18 at 04:44open
andopen location
, bothopen location item 1 of argv
andopen location (item 1 of argv)
– oblitum Jan 22 '18 at 04:46