tags:

views:

211

answers:

1

First time caller, long time listener...

I'm working on a utility that will scan USB ports and mount any Mass Storage devices it finds. I can poll for changes ( with a patched version of Ruby-USB ) but would much rather get a notification, or subscribe to some event.

Is there a way for Ruby to be tickled when a USB stick is inserted?

A: 

Check out ruby-dbus. There is also a tutorial for it as well.

statenjason
By that, I suppose you mean "listen for HAL events"? That works, except that HAL is now deprecated (wow, that was fast ;-) and distributions are moving towards libudev instead.
ephemient
The replacement for HAL is DeviceKit, which does essentially the same thing, except a) it's modular (HAL is a huge monolothic blob) and b) it only implements things that are not available from other libraries, unlike HAL which duplicates a whole bunch of functionality found elsewhere (like libudev). It is still based on D-BUS, though.
Jörg W Mittag
+1 to each of you. Good to know. Will keep in mind the next time I'm trying to pick up hardware notifications.
statenjason
Precisely what I was looking for. Thanks.
Therealstubot