# https://www.reddit.com/r/commandline/comments/8ezevx/udev_only_when_cddvd_inserted/ # ID_CDROM_MEDIA is set by udev KERNEL=="sr0", ACTION=="change", ENV{ID_CDROM_MEDIA_DVD}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/bin/systemctl start autorip@dvd0.service", SYMLINK+="dvd0" KERNEL=="sr1", ACTION=="change", ENV{ID_CDROM_MEDIA_DVD}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/bin/systemctl start autorip@dvd1.service", SYMLINK+="dvd1" KERNEL=="sr0", ACTION=="change", ENV{ID_CDROM_MEDIA_BD}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/bin/systemctl start autorip@bluray0.service", SYMLINK+="bluray0" KERNEL=="sr1", ACTION=="change", ENV{ID_CDROM_MEDIA_BD}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/bin/systemctl start autorip@bluray1.service", SYMLINK+="bluray1" KERNEL=="sr0", ACTION=="change", ENV{ID_CDROM_MEDIA_CD}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/bin/systemctl start autorip@cdrom0.service", SYMLINK+="cdrom0" KERNEL=="sr1", ACTION=="change", ENV{ID_CDROM_MEDIA_CD}=="1", ENV{ID_CDROM_MEDIA_STATE}!="blank", RUN+="/bin/systemctl start autorip@cdrom1.service", SYMLINK+="cdrom1"