launchd from terminal to start app

2019-08-15 13:37发布

问题:

I'm trying to use launchd from terminal to start app with command line arguments. I followed along here but can't figure it out: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/launchd.8.html

I'm trying to launch: /Applications/Firefox.app/Contents/MacOS/firefox -profile "blah blah" -no-remote

thanks!

回答1:

You don't need to directly use launchd for that and probably shouldn't.

You can just use:

open -a Firefox --args -profile "blah blah" -no-remote

Or:

open -a /Applications/Firefox.app --args -profile "blah blah" -no-remote

Or:

open -b org.mozilla.firefox --args -profile "blah blah" -no-remote

If Firefox is already running, then the above will just bring it to the front and activate it. In that case, the args are ignored because they are only meaningful when launching the app.

If you want to launch a new process even if the app is already running, pass the -n option to open, before the --args option. Like:

open -a /Applications/Firefox.app -n --args -profile "blah blah" -no-remote


标签: macos shell