I wouldn't have thought it to be so hard to find this solution, but after weeks of research I have one, and for all those who also need this info, here it is:
Code:
#! /bin/bash
## This script looks for an Audio CD, DVD, data or blank optical disc and echos
## a positive reply, it's up to you to do something useful with it.
device="${1:-/dev/sr0}" # Change the device path to match your optical drive
udi=$(hal-find-by-property --key block.device --string $device | \
while read u ; do \
[[ "$(hal-get-property --udi $u --key block.is_volume)" == "true" ]] && \
[[ "$(hal-get-property --udi $u --key volume.is_disc)" == "true" ]] && \
[[ "$(hal-get-property --udi $u --key volume.disc.is_blank)" == "false" ]] && \
echo $u ; \
done)
if [[ "$udi" != "" ]]; then
if [[ "$(hal-get-property --udi $udi --key volume.disc.has_audio)" == "true" ]]; then
echo "Audio CD detected"
elif [[ "$(hal-get-property --udi $udi --key volume.disc.is_videodvd)" == "true" ]]; then
echo "Video DVD detected"
elif [[ "$(hal-get-property --udi $udi --key volume.disc.has_data)" == "true" ]]; then
if [[ "$(hal-get-property --udi $udi --key volume.is_mounted)" == "false" ]]; then
pmount $device
fi
echo "Data disc detected"
fi
fi