The launcher automatically exits after the wrapped application is launched.It should be possible to make any drag and drop to the launcher automatically redirected to the wrapped application (with a bit more scripting).Automatic updates of the wrapped application should work in most cases.You may now open your application launcher. Result: /Applications/Firefox 3 launcher.app/Firefox 3.app (In this example it would be "Firefox 3.app") Put your application in the root of the package contents. Got to that app in the Finder, right click it, show package contents. set pathToApp to (POSIX path of (path to me)) & "Firefox 3.app"ĭo shell script "open -a \"" & pathToApp & "\" -args -P default -no-remote" Wrap your application inside an AppleScript launcher.Ĭreate an AppleScript with the following content, and save it as an application (in this example it is named "Firefox 3 launcher.app"). The other answers that use open inside do shell script work because open (actually LaunchServices) does the equivalent work of backgrounding the resulting program and sending its stdout and stderr elsewhere. Thus, do shell script will return immediately after the shell exits, allowing the AppleScript application itself to exit (since the do shell script is the last expression in the AppleScript program). The shell’s stdout and stderr ( do shell script’s pipes) are inherited by the programs it runs without redirection (even ones run in the background with &) the redirection ensures that the shell is the last one to hold the writable ends of the pipes. The redirection is required because not only does do shell script wait for its immediate child (the shell) to exit, but it also waits for (all instances of) the writable ends of the pipes it creates for the shell’s stdout and stderr to be closed. It will run long enough to start Firefox and will exit cleanly while Firefox continues to run. (functional line breaks added to keep it “narrow” delete the ¬ and \\ and put it all on one long line if you like) "/Applications/Firefox.app/Contents/MacOS/firefox-bin \\ Use Script Editor to save the following program as an AppleScript application: do shell script ¬ Per TN2065 (under “I want to start a background server process how do I make do shell script not wait until the command completes?”), the proper method is to redirect stdout and stderr and have the shell run the program in the background. Luckily, there is a perfectly reasonable way to do what you need. Something like kill $PPID might be more reasonable, but we may not want to assume that the applet of an AppleScript application is always the immediate parent of the shell started by do shell script. other, concurrently running AppleScript applications (if using “applet” as the pattern)). It can even have untoward side effects if the name/pattern given to killall matches more than just the parent applet process (e.g. It is not necessary (as some other answers have suggested) to use killall (or similar) to kill the parent AppleScript application process (“applet”) in this scenario. Applications/Firefox.app/Contents/MacOS/firefox -P default -no-remote & The only annoyance now is that it opens a dead, logged out Terminal window (which is better than the persistent one, but still.) #!/bin/sh Adding a & to the end of the script kills the persistent Terminal window. So, is there a better way to run applications with command line arguments? If not, is there a way to prevent a persistent terminal session or Applescript icon from staying open while the application is open?Īccording to a Mozilla Wiki page, it's best to use a script to run the application with arguments. ![]() ![]() Presumably, using the Applescript command open would avoid this, but since I'm not running the application as it is packaged (just /Applications/Firefox), it doesn't work. I can make these executable and assign an icon and everything works great except that when I run either of these pseudo programs, either a terminal window or an Applescript icon remains open as long as the application is open. Applications/Firefox.app/Contents/MacOS/firefox -P default -no-remoteĭo shell script "exec /Applications/Opera.app/Contents/MacOS/Opera -kioskmode" I have found that launching the applications through bash or Applescript partially works: # Bash In Windows I can append the arguments to the shortcut properties, but since Macs don't use shortcut per se and run the applications directly, this isn't possible. $ /Applications/Firefox.app/Contents/MacOS/firefox -P profilename -no-remote Is there any easy way to append command line arguments to an application on a Mac? For example, to run Opera in kiosk mode or to use a different profile in Firefox, I can type $ /Applications/Opera.app/Contents/MacOS/Opera -kioskmode
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |