You can use udevadm to see the variables set by udev for a device. This is helpful if you want to get information about the device, based on whether it has a DVD or a CD in there, for example.
udevadm info /dev/sr0
If you want to change any rules, such as in /lib/udev/rules.d
or /etc/udev/rules.d
, you can reload them with udevadm as well:
udevadm trigger
That's what I use when doing my onevent trayclose calls.
In /etc/udev/rules.d/70-persistent-cd.rules
I generate a symlink to /dev/dvd
and /dev/bluray
, as well as call onevent.trayclose
when there is a DVD detected in the drive on an event change (tray closed from being open).
# Sony Blu-ray SUBSYSTEM=="block", ENV{ID_MODEL}=="ATAPI_iHOS104", ENV{ID_REVISION}=="WL0D", SYMLINK+="bluray", ENV{GENERATED}="1" SUBSYSTEM=="block", ENV{ID_MODEL}=="ATAPI_iHOS104", ENV{ID_REVISION}=="WL0D", SYMLINK+="dvd", ENV{GENERATED}="1" SUBSYSTEM=="block", ENV{ID_MODEL}=="ATAPI_iHOS104", ENV{ID_CDROM_MEDIA_DVD}=="1", ENV{ID_CDROM_MEDIA_STATE}=="complete", RUN+="/usr/local/bin/onevent.trayclose"
For completion's sake, here's onevent.trayclose
:
#!/bin/bash mount -o ro -t udf $DEVNAME &> /dev/null if [[ -z "$ID_FS_LABEL" ]]; then ID_FS_LABEL=$(busybox volname $DEVNAME); fi echo "/usr/bin/sudo -u steve /home/steve/Videos/Rip-o-Matic/spincycle $DEVNAME $ID_FS_LABEL" | at now