cdrom_id
For polling devices and getting information sent into udev, the package builds a program called cdrom_id
. It's located at /lib/udev/cdrom_id
. Running it will give information that is passed to udev triggers.
/lib/udev/cdrom_id /dev/sr0
ID_CDROM=1 ID_CDROM_CD=1 ID_CDROM_DVD=1 ID_CDROM_BD=1 ID_CDROM_MRW=1 ID_CDROM_MRW_W=1 ID_CDROM_MEDIA=1 ID_CDROM_MEDIA_DVD=1 ID_CDROM_MEDIA_STATE=complete ID_CDROM_MEDIA_SESSION_COUNT=1 ID_CDROM_MEDIA_TRACK_COUNT=1 ID_CDROM_MEDIA_TRACK_COUNT_DATA=1
You can use it as a poor man's check for a drive status – see if there's something in there or not.
ID_CDROM_MEDIA_DVD=1
will be present if there's a DVD in there (not a CD), and ID_CDROM_MEDIA_STATE=complete
will display if it's finished accessing the device.
However, just because udev is finished, doesn't mean the drive is immediately available. That's why I wrote dvd_drive_status which will check to see if it's really ready to be read.
Using dvd_eject will also wait for the drive to be ready, if you use it to close the tray: dvd_eject -t