1

I have an older iMac running El Capitan. I want to run a shell script when a DVD is inserted. I used Script Editor to create an Applescript that runs the shell script. The Applescript is just

do shell script "sh /Users/shannon/bin/myscript"

I used System Preferences > CDs and DVDs to configure the action when a DVD is inserted to run the Applescript.

It didn't work, DVD Player still runs and the script doesn't.

I used Script Editor to save the script as an application and configured it to run the application.

Still didn't work.

I copied the application to /Applications and changed it to run that copy of the application.

Still didn't work.

I changed the ownership of the application to root (sudo chown -R root /Applications/myapp).

Still didn't work.

No matter what I do, my script/app won't run, and DVD Player runs instead.

What am I doing wrong?

If I run the app by double-clicking on it, it runs correctly and invokes my shell script, so I know the app itself is working correctly.

Do I need to do something special in or to my application to convince the OS that it's capable of running when a DVD is inserted?

(This is very similar to this much older question, which has no answer.)

I tried changing the configuration to open Text Edit when a DVD is inserted, and that didn't work either, so the problem has nothing to do with my program or my script. It appears that this feature just doesn't work at all.

  • Have you also configured the Player options in DVD Player? Mine was set to default: "When a disk is inserted": "Start playing disk" – Wayfaring Stranger Jan 7 '17 at 0:01
  • Yes, sorry, I should've mentioned that. I configured DVD Player to NOT start when a disk is inserted. – Bill Shannon Jan 7 '17 at 0:07
  • Please add the content of the shell script and the Apple script to your question – klanomath Jan 7 '17 at 0:09
  • I assume the contents of the shell script don't matter since it never runs. (It just runs mplayer to rip the contents of the DVD.) I added the Applescript above. – Bill Shannon Jan 7 '17 at 0:16
  • I have a vague recollection that the system preference only applies when you insert a blank disc. Might be worth checking whether that's the case first, before trying to troubleshoot any further? (If that is the case, there's a discussion over on the Apple forums that seems to suggest using Folder Actions might work instead, but it's a bit scarce on details... and ten years old.) – calum_b Jan 7 '17 at 0:26
1

I restarted my system and now this is working, it's invoking my app when the DVD is inserted. There's nothing in the instructions suggesting that a restart is required, but that seems to be the key to making this working. I didn't test whether logging out and logging back in would be sufficient.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .