summaryrefslogtreecommitdiffstats
path: root/tdeeject
diff options
context:
space:
mode:
authorDarrell Anderson <[email protected]>2014-01-06 01:59:59 +0100
committerSlávek Banko <[email protected]>2014-01-06 01:59:59 +0100
commita4a54d1ee3c220a7e698c96a11500a4eba22800a (patch)
treea6d813baaccf364cb717a1223895b580cc3f405d /tdeeject
parent30038436c90a6fbd11c8494fec768bfd2885b89f (diff)
downloadtdebase-a4a54d1ee3c220a7e698c96a11500a4eba22800a.tar.gz
tdebase-a4a54d1ee3c220a7e698c96a11500a4eba22800a.zip
Rename kdeeject -> tdeeject
Diffstat (limited to 'tdeeject')
-rw-r--r--tdeeject/CMakeLists.txt12
-rw-r--r--tdeeject/Makefile.am1
-rwxr-xr-xtdeeject/tdeeject63
3 files changed, 76 insertions, 0 deletions
diff --git a/tdeeject/CMakeLists.txt b/tdeeject/CMakeLists.txt
new file mode 100644
index 000000000..dc57412ec
--- /dev/null
+++ b/tdeeject/CMakeLists.txt
@@ -0,0 +1,12 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+install( PROGRAMS tdeeject DESTINATION ${BIN_INSTALL_DIR} )
diff --git a/tdeeject/Makefile.am b/tdeeject/Makefile.am
new file mode 100644
index 000000000..dd6d3982d
--- /dev/null
+++ b/tdeeject/Makefile.am
@@ -0,0 +1 @@
+bin_SCRIPTS = tdeeject
diff --git a/tdeeject/tdeeject b/tdeeject/tdeeject
new file mode 100755
index 000000000..7adb15570
--- /dev/null
+++ b/tdeeject/tdeeject
@@ -0,0 +1,63 @@
+#!/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 <[email protected]>
+#
+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 TDE app...
+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
+ kdialog --title "TDE Eject" --error "Eject $device failed!"
+fi
+exit 1