I'm trying to make my Cocoa app (a simple video player) to auto-launch every time a removable storage unit is mounted.
Could you guide me, on which schema events should I add a listener, in order to create a small contextual menu when the user connects their flash drive, containing some videos, and ask the user if he wants to play the items with the application X.
Thanks!
If you want to listen for volume mounting events even while your app isn't running, you'll have to create a launchd daemon that runs in the background and registers as an observer for
NSWorkspaceDidMountNotification
. When the notification is posted, your daemon can open your Cocoa app.Otherwise, if you only care about events that happen while your Cocoa app is running, you can listen to the
NSWorkspaceDidMountNotification
directly from your Cocoa app instead of having to use a daemon.