You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.5 KiB
64 lines
1.5 KiB
15 years ago
|
#!/bin/sh
|
||
|
# Script used by kdesktop to eject a removable media (CDROM/Tape/SCSI/Floppy)
|
||
|
# Relies on the 'eject' program, 'cdcontrol' on *BSD
|
||
|
#
|
||
|
# Copyright GPL v2 by David Faure <david@mandrakesoft.com>
|
||
|
#
|
||
14 years ago
|
quiet=0
|
||
|
if test "$1" = "-q"; then
|
||
|
quiet=1
|
||
|
shift
|
||
|
fi
|
||
|
|
||
|
if test "$1" = "--help"; then
|
||
12 years ago
|
echo "Usage: $0 <name> where name is a device or a mountpoint."
|
||
|
exit 0
|
||
14 years ago
|
fi
|
||
|
|
||
|
if test -z "$1"; then
|
||
|
for dev in /dev/cdrom /dev/dvd /dev/dvdram /dev/cdrecorder; do
|
||
12 years ago
|
if test -e $dev; then
|
||
|
lp=`readlink $dev`
|
||
|
if test -n "$lp"; then
|
||
|
device=/dev/$lp
|
||
|
else
|
||
|
device=$dev
|
||
|
fi
|
||
|
break
|
||
14 years ago
|
fi
|
||
|
done
|
||
|
else
|
||
|
device=$1
|
||
|
fi
|
||
|
|
||
|
udi=`dcop kded mediamanager properties $device 2>/dev/null | head -n 1 `
|
||
|
if test -n "$udi"; then
|
||
12 years ago
|
dcop kded mediamanager unmount "$udi" >/dev/null 2>&1
|
||
14 years ago
|
fi
|
||
|
|
||
12 years ago
|
# Checking for stuff in the PATH is ugly with sh.
|
||
11 years ago
|
# I guess this is the reason for making this a TDE app...
|
||
12 years ago
|
OS=`uname -s`
|
||
|
case "$OS" in
|
||
|
OpenBSD)
|
||
|
cdio -f $device eject #>/dev/null 2>&1
|
||
|
;;
|
||
|
*BSD)
|
||
|
dev=`echo $device | sed -E -e 's#/dev/##' -e 's/([0-9])./\1/'`
|
||
|
cdcontrol -f $dev eject #>/dev/null 2>&1
|
||
|
;;
|
||
|
*)
|
||
|
# Warning, it has to be either eject 2.0.x or >=2.1.5
|
||
|
# Otherwise it doesn't work as expected (it requires a
|
||
|
# fstab entry for no reason).
|
||
|
eject -v $device #>/dev/null 2>&1
|
||
|
;;
|
||
|
esac
|
||
|
if test $? -eq 0; then
|
||
|
#dcop kdesktop default refreshIcons
|
||
|
exit 0
|
||
|
elif test $quiet -eq 0; then
|
||
11 years ago
|
kdialog --title "TDE Eject" --error "Eject $device failed!"
|
||
12 years ago
|
fi
|
||
15 years ago
|
exit 1
|