Make OS X run custom actions upon DVD insert

Posted by: gdelmatto  :  Category: Operating Systems, OS X, Programming, Scripting

I’m currently ripping my complete DVD collection off to MKV (Matroska) format, so I can stream them across my home network.

So I sought a way to have my OS X give me the choice to either start DVD Player or MakeMKV upon inserting a DVD.

First I wrote a little AppleScript which gives me the choice. If I’m not taking any action, it will play the DVD automatically after 5 seconds, so it’s very similar to the default behaviour of OS X.

So just run Apple Script-Editor and store this code to a convenient location you like (usually it’s ~/Library/Scripts).

if not appIsRunning("DVD Player") and not appIsRunning("MakeMKV") then
	with timeout of 3600 seconds
		display dialog "Bitte wählen Sie gewünschte Aktion:" with title "Aktion für DVD" buttons {"Cancel", "DVD abspielen", "DVD rippen"} cancel button "Cancel" giving up after (5)
	end timeout
	if button returned of result is "DVD rippen" then
		display dialog "Starte MakeMKV" buttons {"OK"} giving up after 2
		tell application "MakeMKV" to activate
	else if button returned of result is "Cancel" then
		display dialog "Starte DVD-Player" buttons {"OK"} giving up after 2
		tell application "DVD Player" to activate
	end if
end if

on appIsRunning(appName)
	tell application "System Events" to (name of processes) contains appName
end appIsRunning

Then go to system properties and select CDs & DVDs properties. Beneath “When you a insert a Video-DVD” choose “Run Script” and locate the script file you created before.

From now on, you’ll be presented with a selection prompt. Doing nothing will automatically start the DVD Player, or the DVD Ripper, if you choose to do so.
Quiet cool, isn’t it? 😉

Comments are closed.