Xfce Volstatus Icon 0.1.0

Yesterday I released the first version of my Xfce Volstatus Icon. It’s a pretty simple little app; all it does is sit quietly (and invisibly) in your system tray until you plug in a removable device (like a USB flash disk or an iPod), and then it turns into a little icon that you can click to easily and safely unmount and/or eject the device so you can physically remove it.

The code for the icon itself is relatively simple; it’s all less than 2000 lines of C. Another 2000 lines resides in ‘ghal’, a library I’ve written to act as gobject bindings for libhal and libhal-storage. Currently it’s not documented at all, and it’s not released as a separate library dependency, but included in the xfce4-volstatus-icon source package. I first wrote the libhal bindings for Airconfig, and then extended them for volstatus to include libhal-storage.

The upshot is that you can create a GHalContext object, and connect to gsignals on the object such as device-added and device-removed. You can enumerate devices (GHalDevice objects) on the system via their UDIs. Now ghal also knows about ‘special’ devices, which are subclasses of GHalDevice: GHalDrive, GHalVolume, and GHalVolumeDisc. The cool thing is that you don’t have to know what they are explicitly. ghal_context_device_from_udi() will create the right kind of device and return it to you cast to a GHalDevice; you can use e.g. GHAL_IS_DRIVE() to determine if it’s also a GHalDrive, etc. Currently you can use ghal_context_find_device_by_capability() to find devices of particular types if you know the HAL capability strings, but I plan to add convenience API to abstract the capability strings.

I’d also like to add more objects, like GHalComputer (the root computer object), and support for performing actions on particular devices (like mount/unmount for volumes, suspend/hibernate for the power management interfaces, etc.). I’m also debating including some parts of Airconfig in there as well (mainly the interface control stuff), though I’m not yet convinced that that’s necessary or useful, especially since it currently relies on a custom HAL addon and method-invocation scripts. At any rate, I think it’s pretty useful for people who want to use HAL just like any other glib/gobject-type services, and I’ll turn it into a standalone library Real Soon Now[tm].

(Yes, I know about libhal-glib, written by Richard Hughes for gnome-power-manager. However, I don’t really like the API that much, and it obviously has a decidedly power-management-slanted focus that I don’t need.)