diff options
author | albator <albator@arcadia.vtf> | 2011-10-21 20:16:07 +0200 |
---|---|---|
committer | albator <albator@arcadia.vtf> | 2011-10-21 20:16:07 +0200 |
commit | 7a0adf35896618a7570e425941fc1b74c54def47 (patch) | |
tree | 16dab9d8bfbd93575440f357c70907cbb5480980 /mandriva/2010.2/kdebase/kdeeject | |
parent | cd71be65dc30c8007ec54becdf6c50260ed8e908 (diff) | |
parent | a8707e2a9f22d082cecb8ea6079175076f983c55 (diff) | |
download | tde-packaging-7a0adf35896618a7570e425941fc1b74c54def47.tar.gz tde-packaging-7a0adf35896618a7570e425941fc1b74c54def47.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tde-packaging
Diffstat (limited to 'mandriva/2010.2/kdebase/kdeeject')
-rw-r--r-- | mandriva/2010.2/kdebase/kdeeject | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/mandriva/2010.2/kdebase/kdeeject b/mandriva/2010.2/kdebase/kdeeject new file mode 100644 index 000000000..557b0179f --- /dev/null +++ b/mandriva/2010.2/kdebase/kdeeject @@ -0,0 +1,77 @@ +#!/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> +# +quiet=0 +if test "$1" = "-q"; then + quiet=1 + shift +fi + +if test "$1" = "--help"; then + echo "Usage: $0 <name> where name is a device or a mountpoint." + exit 0 +fi + +if test -z "$1"; then + for dev in /dev/cdrom /dev/dvd /dev/dvdram /dev/cdrecorder; do + if test -e $dev; then + lp=`readlink $dev` + if test -n "$lp"; then + device=/dev/$lp + else + device=$dev + fi + break + fi + done +else + device=$1 +fi + +udi=`dcop kded mediamanager properties $device 2>/dev/null | head -n 1 ` +if test -n "$udi"; then + dcop kded mediamanager unmount "$udi" >/dev/null 2>&1 + + block_udi=`hal-get-property --udi $udi --key block.storage_device` + + if test -n "$block_udi"; then + need_eject=`hal-get-property --udi $block_udi --key storage.requires_eject` + if test "$need_eject" = "false"; then + exit 0; + fi + fi +fi + + # Checking for stuff in the PATH is ugly with sh. + # I guess this is the reason for making this a kde app... + OS=`uname -s` + case "$OS" in + OpenBSD) + cdio -f $1 eject >/dev/null 2>&1 + ;; + *BSD) + dev=`echo $1 | 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_result=$(dbus-send --system --print-reply --dest=org.freedesktop.Hal $block_udi org.freedesktop.Hal.Device.Storage.Eject array:string:"" | grep int | cut -d\ -f5) + # fallback if not true + if [ "$eject_result" != "0" ]; then + eject $1 >/dev/null 2>&1 + fi + ;; + esac + if test $? -eq 0; then + dcop kdesktop default refreshIcons + exit 0 + elif test $quiet -eq 0; then + kdialog --title "KDE Eject" --error "Eject $1 failed!" + fi + +exit 1 |