In my linux bash script I want to wait for one of the following events:
- DVD drive tray was closed by the user,
or
- writeable DVD was inserted to the drive.
Unfortunately all the commands to check the media in drive first close the tray and I don't want to do that - it should stay open and wait for DVD being inserted by the user.
Could you please advice me how to do that?
This is highly platform specific. What you might need to do is either (a) parse
/var/log/messages
for ascpi events, or (b) depending on platform, monitor DBUS for changes. When you open and close the tray, events are generated that can be detected, but this may be more trouble than its worth. Regardless, the DBUS method will work for popular distros such as Fedora and Ubuntu out of the box.Good luck; I'm definitely interested in seeing how this turns out!
EDIT: Found a good blog post that does this from Python, but since DBUS is designed to be application agnostic, you can use some of the values from the page.
I managed to solve the problem using:
It checks if the media inserted is blank, without closing the tray.