Tag Archives: gudev

If only it had been deprecated in 2001

You know that any post about deactivating HAL will, at some point, link to a bucket of bolts singing “Daisy Bell”, so I’ll do it now and get it over with.

The past couple of days I’ve been removing from Shotwell the deprecated (and despised!) HAL.  Shotwell’s reliance on HAL is minimal.  Most hardware interaction is through gPhoto.  What Shotwell needs is notification of devices being attached or detached (to run a gPhoto auto-detect) and a way of mapping USB ports to gPhoto camera objects (due to some legacy libusb port-naming stuff — see this and this).  udev is the preferred replacement (although there’s still some information out there saying to use DeviceKit; don’t).  Unfortunately, there’s no Vala bindings for gudev (a GObject-wrapper), so I had to build my own.

It turns out the Vala documentation for making bindings for GObject-based libraries has improved considerably, and I had a workable VAPI in just a couple of hours.  (It’s here for those interested in its state.)

gudev has a signal for when devices are added, removed, changed, etc.  That’s good.  However, it doesn’t provide a way to get subsystem-specific device information (i.e. whether a USB device is a PTP camera).  The solution was to walk the USB bus (via libusb) and match bus/device IDs with gPhoto’s auto-discovered port strings.  And that’s all there was to it.

HAL offered everything we needed (signalling and USB-specific device type information), so I can’t say I’m on the good-riddance bandwagon.  I’m not cheerleading for it either, though  Like a casual acquaintance with whom you don’t have much in common, it’s easy to say sayonara to HAL.