Get notified when a new application is installed?

Is there a way to get a notification of some type when a new application is installed?

The specifics here have to do with "Here is a list of applications we want to monitor"; I use mdquery to find them (so I can get the paths, and information from the bundle). However, if it's not installed yet, then I can't do that. But if it gets installed later, I'd like to.

I guess I wasn't clear -- I don't want notifications from my app, I want to find out when an application is installed. Or removed, that would be nice too, but less important.

What kind of app and do you want to keep monitoring while app is closed?

Are you using kMDQueryWantsUpdates to keep monitoring while the app is open?

Ideally I'd put this in one of the daemons, so that monitoring won't be a problem. I am not currently using kMDQueryWantsUpdates... but can I? That is, will it keep working forever?

Ideally I'd put this in one of the daemons, so that monitoring won't be a problem. I am not currently using kMDQueryWantsUpdates... but can I? That is, will it keep working forever?

MDQueryExecute(query, CFOptionFlags(kMDQueryWantsUpdates.rawValue)) will keep monitoring forever with kMDQueryDidUpdateNotification notifications after the initial kMDQueryProgressNotification and kMDQueryDidFinishNotification notifications.

Note: In a command line context you'll probably need a manual RunLoop for the notifications to fire.

Might also be worth looking at the higher level NSMetadataQuery with enableUpdates().

I couldn't get NSMetadataQuery to work outside of a GUI context, while the C api did. So...

This is helpful thank you!

Get notified when a new application is installed?
 
 
Q