Hi, I have an application that as part of its activation installs a launch agent in the current users ~/Library/LaunchAgents/. The launch agent watches a folder path and when required launches the UNIX command open to locate and launch a background application within the original application package. This all seems to be working fine. If a user chooses to stop using the application they are asked to deactivate it by opening it and pressing a 'deactivate' button. The main reason for this is to deactivate the associated launchd job. However some users of the app. are deleting the application package without doing this. This leaves the user with an orphaned launchd job calling 'open' to find an application that is not on the user's system. Open returns an error and the launchd job returns 'code 1'. This will repeat on a regular basis. I am looking for advice as to how best avoid this eventuality. My initial thought was to host the launchd.plist inside the application package and soft link to it. This won't help because the WatchPath is inside the users account. I tried using a tilde to replace the user's folder path in the WatchPath, but evidently this does not get expanded by launchd. Another option could be to create a plist per user within the application package and soft link to it from ~/Library/LaunchAgents/. This doesn't seem like much of a solution to me. Can you suggest a better solution? Is there a reason for launchd not to expand tilde on launch agent paths? Thanks for your time. John (I am reading in digest mode, so please cc my email address)
On Thu, Jun 26, 2008 at 8:26 PM, John Maisey <john@nhoj.co.uk> wrote:
Can you suggest a better solution?
Instead of your launchd agent trying to open an application on the user's system, it could call an executable installed in ~/Library/Application Support/YourApp which would open the application if it exists, and remove itself and the launchd agent if not. Hamish
On 26 Jun 2008, at 22:47, Hamish Allan wrote:
On Thu, Jun 26, 2008 at 8:26 PM, John Maisey <john@nhoj.co.uk> wrote:
Can you suggest a better solution?
Instead of your launchd agent trying to open an application on the user's system, it could call an executable installed in ~/Library/Application Support/YourApp which would open the application if it exists, and remove itself and the launchd agent if not.
Hamish
Thanks for this Hamish. It sounds like it would do the trick. Best wishes John
participants (2)
-
Hamish Allan
-
John Maisey