-
Notifications
You must be signed in to change notification settings - Fork 4
dvd_drive_status
The dvd_drive_status program will check the kernel to get an accurate state of the optical drive. This is necessary if you are waiting to know exactly when a drive is completely ready to poll.
The eject program (through no fault of its own) will send a command to the optical drive to close its tray, and then exit. The drive, however, can be in a polling state, meaning it is accessing the disc, or waiting for the components to become ready.
There are four states that an optical drive can be in:
- open
- closed with no disc
- closed with a disc
- polling
1 - no disc 2 - tray open 3 - drive not ready 4 - closed with disc 5 - path / filename is not a DVD drive 6 - could not open path / filename 7 - unknown error
Here's an example of waiting for a drive to be closed:
#!/bin/bash eject -t while true; do drive_status=`dvd_drive_status > /dev/null` if [[ $? -eq 4 ]]; then break; fi sleep 1 done
Alternatively, you can use dvd_eject to close a tray and return control once it has finished polling.
Each OS has different access options to the optical drive hardware, and therefore not all options are supported on each. They can all detect if a tray is open or closed though, but not necessarily polling. GNU/Linux can track them all.