On Fri, 2009-04-24 at 13:07 +0200, Andreas Heinlein wrote: > Alexander Larsson schrieb: > > On Thu, 2009-04-23 at 10:10 +0200, Andreas Heinlein wrote: > > > >> Hello, > >> > >> I need to write a small app which will catch volume mounts and unmounts > >> as well as drive insertions/removal. > >> > >> I have written a Perl daemon for that, which hooks to the signals > >> "drive-connected", "drive-disconnected", "volume-mounted" and > >> "volume-pre-unmount" of a Gnome2::VFS::VolumeMonitor object. Getting > >> "volume-mounted" or the disk signals works just fine, but I never get > >> "volume-pre-unmount". > >> > >> I have no idea why, I already asked on the gtk2-perl mailing list but > >> got no answer. In addition, I noticed that I am not getting > >> "drive-connected" any more und Ubuntu Jaunty when the drive in question > >> contains no recognized file system. This is bad because one use for this > >> app is to auto-mount TrueCrypt encrypted volumes. > >> > >> I suspect this has to do with deprecation of GnomeVFS, but Python and > >> Perl (the languages I know best) bindings for GVFS seem to not exist or > >> are badly documented. > >> > >> Can anyone help me with this? > >> > > > > You only get volume-pre-unmount when unmounting via gnome-vfs. And > > unfortunately, everything in the desktop now unmounts via gio, so you > > need to use that to get this. > > > > GVfs has no bindings, because it doesn't have an API, its purely an > > extension of glib. All the API is in gio (in glib), which is availible > > at least in the python bindings. > > > > > Thanks for your help. I found out how to get a GVolumeMonitor reference > with Python, but the situation is now even worse. I tried connecting to > all signals of GVolumeMonitor, but this time I get only "mount-added" > and "mount-removed". Still no pre-unmount, and no drive-(dis)connected > (I have yet to find out what "volume-(dis)connected" means here). I > managed to get the "unmounted" signal of a GMount returned by above > signals, but that's too late; I need to be able to write to the > filesystem being unmounted.
Pre-unmount was actually only implemented very recently, so you need gnome 2.26. > Also, I noticed that the output of e.g. get_mounts() in my app does > never change. I.e. this code snippet: > > #!/usr/bin/python > import gio, time > while True: > print gio.volume_monitor_get().get_mounts() > time.sleep(1) > > will always show the state when it was invoked, but will never display > new mounts and keep displaying mount which where removed in the meantime. Yes, for this to work you must be running the glib mainloop. _______________________________________________ gnome-devel-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gnome-devel-list
