Posts: 4
Joined: Mon Oct 08, 2012 8:09 pm

Action on audio CD insert

Tue Feb 26, 2013 9:07 pm

I've attached an external CD/DVD drive to my (headless) RPi and I want to rip an audio CD (using the excellent abcde) every time one is inserted. Ideally, I'd like to do the same with HandBrake on DVDs, but one step at a time.

I did the standard web bashing and could not find a good recipe for this. There seem to be several competing tools of various ages, including halevt and udev. I can't make much sense of the documentation for either and I also find worrying signs of hacky workarounds for basic missing functionality, see the constantly-polling Perl script on this thread:

Does anybody know how to use a RPi to launch a shell command on CD insert?


Posts: 281
Joined: Sat Feb 02, 2013 12:41 pm
Location: Berkshire, UK

Re: Action on audio CD insert

Fri Mar 01, 2013 8:47 pm

I've always thought that udev was current best practice. Not used halevt but have recently played around with udev albeit not on a Raspberry.

Seemed quite straight forward; these URLs were of the most use:

Of particular use is the udevadm tool, referenced in the above links, with command like

Code: Select all

udevadm info -q path -n /dev/ttyUSB0
udevadm info -a -p $(udevadm info -q path -n /dev/ttyUSB0)
udevadm monitor –env
udevadm trigger
The last is useful to emulate the insert of the device. The earlier commands, along with lsusb and the out of /var/log/messages, help to determine the characteristics of the device you are plugging. These are critical to getting the trigger event you require; in my case a USB UART with an XBee module.

I triggered a simply bash script, starting with x+ugo permissions just to get up and running.

Hope this is helpful

Return to “Beginners”