How can I detect when a flash drive is plugged in? I’m using a bare Debian installation, without any GUI and want to be notified in my Python script when a new flash drive appears… I know that D-BUS distributes such information, but i dont want to use D-BUS. Is there a more bare access to that information? Shouldn’t that be available under /proc or /sys? How can I “connect” to that source?
Bye
falstaff
You can read uevents from kernel via a Netlink socket and look for events where
"ACTION"is"add"(you can also watch if a partition from a device was mounted or unmounted, or if a device is being removed). That’s as close to the source of events as one can get in user space. As far as I know, this is howudevdetects inserted removable media.But probably using D-Bus/HAL API via Python bingings will be much easier (no uevents data parsing, etc). Not sure why you are opposed to this. Since you are using Python, I suspect that resources are not really the issue.