XDeviceInfo *info;
int loop;
int shortformat = False;
+ int daemon = False;
shortformat = (argc == 1 && strcmp(argv[0], "--short") == 0);
+ daemon = (argc == 1 && strcmp(argv[0], "--loop") == 0);
- if (argc == 0 || shortformat) {
+ if (argc == 0 || shortformat || daemon) {
int num_devices;
-
- 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);
} else {
int ret = EXIT_SUCCESS;
/*
* Copyright 1996 by Frederic Lepied, France. <Frederic.Lepied@sugix.frmug.org>
- *
+ *
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
- * is provided "as is" without express or implied warranty.
- *
+ * is provided "as is" without express or implied warranty.
+ *
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
#endif
);
-typedef struct
+typedef struct
{
char *func_name;
char *arg_desc;
set_mode
},
{"list",
- "[--short || <device name>...]",
+ "[--loop || --short || <device name>...]",
list
},
{"query-state",
{
XExtensionVersion *version;
Bool present;
-
+
version = XGetExtensionVersion(display, INAME);
if (version && (version != (XExtensionVersion*) NoSuchExtension)) {