Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have an external drive. Is it possible to launch a program or perform an action when I connect it or plug it in?

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

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

share|improve this answer
    
Thank, it works! Steps to configure Marco Polo: (1) Create a context, e.g. DTVP (2) Plug the drive, create a USB rule for this context and increase its confidence to 100% (3) Setup an Open action for /Volumes/DTVP/Mac/DTVP.app. Voilà! –  pesche Jan 5 '11 at 22:07
add comment

A similar question has been posted in the MacRumors forum here:

http://forums.macrumors.com/showthread.php?t=1029207

The specific suggestion there is to use the application MarcoPolo.

share|improve this answer
add comment

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.

share|improve this answer
    
Here's is an interesting link about launchd approach: macscripter.net/viewtopic.php?id=32534 –  Somebody still uses you MS-DOS Oct 10 '11 at 6:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.