Ludwig Nussel wrote:
> Carl-Daniel Hailfinger wrote:
>> Ludwig Nussel wrote:
>>> On Thursday 14 September 2006 14:02, Bernhard Walle wrote:
>>>> * Ludwig Nussel <[EMAIL PROTECTED]> [2006-09-14 13:12]:
>>>>> By calling the Eject() method of the object that represents the device
>>>>> in hal.
>>>> Is there a command line utitlity to achieve this? It would be also
>>>> interesting if there's a command line utility to perform
>>>> mount/unmount.
>>> You can use dbus-send to call any method. For mount/umount there is
>>> halmount (package ivman)
>> Working example please. Especially for the eject call.
>>
>> According to the dbus-send man page, the following should work.
>> But it simply does nothing, even if the CD is no longer mounted.
>> dbus-send --system --dest=org.freedesktop.Hal.Device.Volume
>> /org/freedesktop/Hal/devices/volume_label_K3b_data_CD
>> org.freedesktop.Hal.Device.Volume.Eject
>
> dbus-send --system --print-reply --dest=org.freedesktop.Hal \
> /org/freedesktop/Hal/devices/volume_label_foo \
> org.freedesktop.Hal.Device.Volume.Eject \
> array:string:
Would you please merge the first attached patch into halmount
(against halmount from factory) and the second attached patch
into the ivman config files?
That would give us the complete eject button functionality.
Thanks!
Carl-Daniel
--- /usr/bin/halmount.py 2006-05-19 19:06:04.000000000 +0200
+++ halmount.py 2006-10-04 18:27:35.000000000 +0200
@@ -233,6 +233,28 @@
return ret
+ def eject(self, name):
+ ret = 0
+ found = False
+ if name != "/": name = name.rstrip("/")
+
+ for dev in self.mountable:
+ if (self.all or (name[0:5] == "/dev/" and dev.device ==
name) or dev.mountpoint == name):
+ found = True;
+ obj =
self.bus.get_object("org.freedesktop.Hal", dev.udi)
+ try:
+ ret = obj.Eject([""],
dbus_interface="org.freedesktop.Hal.Device.Volume")
+ except dbus.DBusException, msg:
+ err(dev.device + ": " + str(msg))
+ ret += 1;
+
+ if found == False:
+ if name != "": err(name + " not found")
+ else: err("no device found")
+ ret += 1
+
+ return ret
+
parser = OptionParser(usage="%prog [options] <device|label> [mountpoint]")
parser.add_option("-t", dest="fstype", default="",
help="file system type")
@@ -242,6 +264,8 @@
help="verbose listing")
parser.add_option("-u", dest="umount", action="store_true", default=False,
help="umount")
+parser.add_option("-e", dest="eject", action="store_true", default=False,
+ help="eject")
parser.add_option("-a", dest="all", action="store_true", default=False,
help="(u)mount all")
parser.add_option("--listudi", dest="listudi", action="store_true",
default=False,
@@ -258,7 +282,7 @@
m.verbose = options.verbose
m.all = options.all
-if options.umount == True:
+if (options.umount == True) or (options.eject == True):
if len(args) != 1 and options.all == False:
err("specify device name or mountpoint")
sys.exit(1)
@@ -268,7 +292,10 @@
except:
name = ""
- m.umount(name)
+ if options.umount == True:
+ m.umount(name)
+ else:
+ m.eject(name)
elif options.listudi == True:
m.listudi()
else:
--- /etc/ivman/IvmConfigConditions.xml 2006-05-19 19:06:03.000000000 +0200
+++ IvmConfigConditions.xml 2006-10-04 18:48:09.000000000 +0200
@@ -43,4 +43,10 @@
</ivm:Match>
-->
+ <!-- eject the drive if the eject button has been pressed
+ -->
+ <ivm:Match name="hal.storage.requires_eject" value="true">
+ <ivm:Condition name="EjectPressed" exec="/usr/bin/halmount.py -e
'$hal.block.device$'" />
+ </ivm:Match>
+
</ivm:ConditionsConfig>