Re: usb plug/unplug notifications

On Thu, 9 Jul 2009 17:38:24 -0500
"Garth's KidStuff" <garthskidstuff gmail com> wrote:

I'd like to know how to intercept usb events.  Right now, I'm polling
for changes, but that isn't the "right" way to handle device
discovery.  Is there a way to get a notification when something happens
in the usb world?

In recent distributions, udev is used. udev manages all hardware events,
and executes rules which are located in (possibly several) locations.
One such location is /usr/udev/rules. You can edit those rules to make
events call your programs, modify things, etc. 

The syntax of the rules is relatively simple and powerful, and you can
edit them with a simple editor. The command

udevadm monitor

will show you the events on the terminal, as a way to look at the events
that are detected. Do a 'man udev' for more info.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]