-
- info = XListInputDevices(display, &num_devices);
-
- for(loop=0; loop<num_devices; loop++) {
- print_info(info+loop, shortformat);
- }
+ XEvent ev;
+ int daemon = argc;
+
+ if (daemon)
+ {
+ XiSelectEvent(display, DefaultRootWindow(display),
+ XI_DeviceHierarchyChangedMask);
+ }
+
+ do {
+ info = XListInputDevices(display, &num_devices);
+ for(loop=0; loop<num_devices; loop++) {
+ print_info(info+loop, shortformat);
+ }
+
+ /* just wait for the next generic event to come along */
+ while (daemon && !XNextEvent(display, &ev))
+ {
+ if (ev.type == GenericEvent)
+ break;
+ }
+ } while(daemon);