Automatically launch a program or action when an external drive or disk is connected
Solution 1:
Marco Polo can perform actions (you specify) based on attached USB devices.
Edit: MarcoPolo isn't supported anymore, but there is a maintained fork of it: ControlPlane
Solution 2:
The likely most robust solution is to create a launchd
job with the StartOnMount
property set to -boolean YES
:
StartOnMount <boolean>
This optional key causes the job to be started every time a filesystem is mounted.
This is how Time Machine does it (see /System/Library/LaunchDaemons/com.apple.backupd-attach.plist
).
You need to check if the desired /Volume/...
is available, but in my experience, it's faster than using Folder Actions.