Search code examples
macoslaunchdlaunchdagent

should we use .app bundle or the unix exe of the GUI app for launching as an Agent


I wanted to launch a GUI Application as a User Agent in Macos, but I m not sure about the right way of doing it. I m aware of 2 ways and wanted to know which should be used and why?

  1. Using the Unix exe present in the .app application bundle for my GUI app. In that case the program entry in the .plist file for the Agent will look like this:

enter image description here

  1. Using the .app application bundle itself. We cannot directly provide the path for the .app file hence, I m using a script for that. In that case the program entry in the .plist file for the Agent will look like this:

enter image description here

Note: The LaunchGUI.sh is script which uses the 'open' command to launch the GUI .app bundle.


Solution

  • From the Apple man page:

    Program <string>.
    This key maps to the first argument of execv(3) and indicates the absolute path to the executable for the job.

    Means you have to specify the path to a shell script or UNIX executable, in case of an application (bundle) the file in ./Contents/MacOS.


    If you want to launch an application by its bundle path use /usr/bin/open with the -a or -W flag.