I want to launch a specific app when a USB device is plugged in to a Mac OS X system. I've followed the recipe given in this SO post. But it appears the LaunchEvents
key is not recognized: When I reboot my system, I see the following message on the console:
com.apple.launchd.peruser.501[173] (com.example.program) Unknown key for dictionary: LaunchEvents
I am running OS X 10.6.8, and it's entirely possible that xpc_events aren't supported in this version of OS X. If this is the case, what are my alternatives?
(As a second, lesser question: is there a way to force a re-read of my .plist file without rebooting the system? It would speed up debugging time!)
The entire contents of ~/Library/LaunchAgents/com.example.plist
follows. (Note that for debugging, I'm simply trying to launch the Terminal.app using /usr/bin/open. I'll swap in my real program once I get this much working.)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.program</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>/Applications/Utilities/Terminal.app</string>
</array>
<key>LaunchEvents</key>
<dict>
<key>com.apple.iokit.matching</key>
<dict>
<key>com.apple.device-attach</key>
<dict>
<key>idProduct</key>
<integer>8963</integer>
<key>idVendor</key>
<integer>1659</integer>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>IOMatchStream</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>