There's no standard way to specify a dependent app. So, you need to somehow watch the system. You don't have to actively poll; you need to use some system mechanism to tell you.
To watch for a GUI app to launch, you need to write a background app, get the NSWorkspace's notification center by
NSNotificationCenter* nc=[[NSWorkspace sharedWorkspace] notificationCenter];
and watch for NSWorkspaceDidLaunchApplicationNotification. See the Apple doc
.
To watch for a non-GUI app to launch, you need to use kqueue
. (This is a BSD feature.) See the man page. Typically you have to watch launchd
to fork
or execve
processes. Note that there are multiple launchd
processes, one for root and one for each logged-in users.
In any case you need to start automatically the background app you write. There're many ways to do that.
To watch a file or a directory to change, you can use launchd
agents. See the man page.
By the way: the official Last.fm
app, on its first launch, installs AudioScrobbler.bundle
inside ~/Library/iTunes/iTunes Plug-ins
. iTunes reads all the plug-ins when launched, and the plug-in then launches the Last.fm app. It's a rather hackish, non-condoned usage of the interface, because the plug-in is for the visualizer. See Apple doc.