Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I start a Program.app with LaunchDaemons (launchd)?

Tags:

macos

launchd

I've placed the following com.apple.test.plist file in the folder:

/System/Library/LaunchDaemons

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.apple.Spotlight</string>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>

But for some reason ApplicationTest.app does not start when i login with my user todd.

Any ideas?

like image 212
Alosyius Avatar asked Aug 08 '13 19:08

Alosyius


1 Answers

The key ProgramArguments expects an executable file but you provided an application bundle, which is a glorified directory. In order to start the application you have to point launchd to the executable inside the bundle:

<key>ProgramArguments</key>
<array>
<string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app/Contents/MacOS/ApplicationTest</string>
</array>

Alternatively use the open(1) command to run the application:

<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-W</string>
<string>/Users/todd/Dropbox/client/CLIENT.BUILDS/MAC/v0.1/ApplicationTest.app</string>
</array>
like image 175
LCC Avatar answered Sep 22 '22 17:09

LCC