File indexing completed on 2024-04-28 16:44:24

0001 #!/bin/sh
0002 # Script used by kdesktop to eject a removable media (CDROM/Tape/SCSI/Floppy)
0003 # Relies on the 'eject' program, 'cdcontrol' on *BSD
0004 #
0005 # Copyright GPL v2 by David Faure <david@mandrakesoft.com>
0006 #
0007 if test $# -ge 1 -a "$1" != "--help"; then
0008   quiet=0
0009   if test "$1" = "-q"; then
0010     quiet=1
0011     shift
0012   fi
0013   # Checking for stuff in the PATH is ugly with sh.
0014   # I guess this is the reason for making this a kde app...
0015   OS=`uname -s`
0016   case "$OS" in
0017     OpenBSD)
0018       cdio -f $1 eject >/dev/null 2>&1
0019       ;;
0020     *BSD)
0021       dev=`echo $1 | sed -E -e 's#/dev/##' -e 's/([0-9])./\1/'`
0022       cdcontrol -f $dev eject >/dev/null 2>&1
0023       ;;
0024     *)
0025       eject $1 >/dev/null 2>&1
0026       ;;
0027   esac
0028   if test $quiet -eq 0; then
0029     kdialog --title "KDE Eject" --error "Eject $1 failed!"
0030   fi
0031 else
0032   kdialog --title "KDE Eject" --msgbox "Usage: $0 <name> where name is a device or a mountpoint."
0033 fi
0034 exit 1