summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdebase/kdeeject.diff
blob: d22e67fb616a2c9836deb85f5b64bc017ba29712 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Index: kdeeject/kdeeject
===================================================================
--- kdeeject/kdeeject.orig
+++ kdeeject/kdeeject
@@ -4,12 +4,38 @@
 #
 # Copyright GPL v2 by David Faure <david@mandrakesoft.com>
 #
-if test $# -ge 1 -a "$1" != "--help"; then
-  quiet=0
-  if test "$1" = "-q"; then
-    quiet=1
-    shift
-  fi
+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
+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`
@@ -34,7 +60,5 @@ if test $# -ge 1 -a "$1" != "--help"; th
   elif test $quiet -eq 0; then
     kdialog --title "KDE Eject" --error "Eject $1 failed!"
   fi
-else
-  kdialog --title "KDE Eject" --msgbox "Usage: $0 <name> where name is a device or a mountpoint."
-fi
+
 exit 1