Is there any daemon/tool which will trigger some signal/event when USB keyboard is plugged and unplugged from pc? I need to know in my program when USB keyboard is plugged and unplugged. Any ideas on how to do this?
udev (Linux device manager) is the one that polls hardware. When it detects some changes about devices, it executes the rule associated.
You should add a rule to udev, in order to inform your program about insertion of removal of USB keyboard. You can find documentation about udev rules here, or Look at files in /etc/udev/rules.d/
or /lib/udev/rules.d/
to find many examples.
udevadm monitor
(the udev administration binary) or udev_monitor
(in libudev).
Alternately, if you're running in X11 with input hotplugging, you can listen for the XI extension event DevicePresenceNotify
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With