Search code examples
linuxevdev

How to determine when new devices are added with evdev?


What is the preferred way to determine when new devices become available as /dev/input/eventX?

Do I have to periodically examine the /dev/input directory, comparing my open files against the list of /dev/input/eventX devices, or is there a simpler way?

I have taken a brief look at hotplug.txt, but I think that would notify me of the underlying raw /dev/input device creation, and not necessarily the corresponding /dev/input/eventX creation.


Solution

  • You can use inotify. Something like inotifywait -r -m /dev/input