I'm using a
launchd agent to run a shell script whenever I connect my thunderbolt dock. I've been able to use
IOKit notifications to detect when the dock is being attached, but I also want to run a shell script whenever the dock is being detached.
To detect the attachment of the dock I use
<key>LaunchEvents</key> <dict> <key>com.apple.iokit.matching</key> <dict> <key>com.apple.device-attach</key> <dict> <key>IOProviderClass</key> <string>IOPCIDevice</string> <key>idVendor</key> <integer>21</integer> <key>idProduct</key> <integer>4</integer> <key>IOMatchStream</key> <true/> <key>IOMatchLaunchStream</key> <true/> </dict> </dict> </dict>
There should be an event that is fired on detach too, although I haven't fond it yet. The apple documentation on this subject is deplorable.
I really want to avoid using a polling method that keeps checking if the device is still attached. Some better solutions must
Also growl, ControlPlane and other similar apps are out of the question.
To be clear. I want to run a shell script every time this specific dock is connected or disconnected, not whenever any device is attached/detached.