Udev monitors hardware and forward events on dbus. You just need a dbus listener. A quick check with the dbus monitor tool shows this on my system:
dbus-monitor - system
signal sender=:1.15 -> dest=(null destination) serial=144 path=/org/freedesktop/UDisks; interface=org.freedesktop.UDisks; member=DeviceChanged
object path "/org/freedesktop/UDisks/devices/sr0"
This is a DeviceChanged event from Udisks, and the device path is enabled.
So, in any programming language that you need that supports dbus bindings, you can listen to events (system bus).
source
share