[launchd-dev] automatic job removal
John Maisey
john at nhoj.co.uk
Thu Jun 26 12:26:34 PDT 2008
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)
More information about the launchd-dev
mailing list