The default output of xinput list is hard to parse by scripts. Provide a
--id-only option to print the device ID only, without any other
information.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dirk Wallenstein <halsmit@t-online.de>
Tested-by: Dirk Wallenstein <halsmit@t-online.de>
require a device name.
.PP
.TP 8
require a device name.
.PP
.TP 8
-.B --list [--short || --long || --name-only] [\fIdevice\fP]
+.B --list [--short || --long || --name-only || --id-only] [\fIdevice\fP]
If no argument is given list all the input devices. If an argument is given,
show all the features of \fIdevice\fP.
If --long is provided, the output includes detailed information about the
If no argument is given list all the input devices. If an argument is given,
show all the features of \fIdevice\fP.
If --long is provided, the output includes detailed information about the
If --name-only is provided, the output is limited to the device names. One
device name is listed per line. Note that the order the devices are listed
is undefined.
If --name-only is provided, the output is limited to the device names. One
device name is listed per line. Note that the order the devices are listed
is undefined.
+If --id-only is provided, the output is limited to the device IDs. One
+device ID is listed per line. Note that the order the devices are listed is
+undefined.
.PP
.TP 8
.B --get-feedbacks \fIdevice\fP
.PP
.TP 8
.B --get-feedbacks \fIdevice\fP
enum print_format {
FORMAT_SHORT,
FORMAT_LONG,
enum print_format {
FORMAT_SHORT,
FORMAT_LONG,
+ FORMAT_NAME,
+ FORMAT_ID,
{
printf("%s\n", info->name);
return;
{
printf("%s\n", info->name);
return;
+ } else if (format == FORMAT_ID)
+ {
+ printf("%ld\n", info->id);
+ return;
}
printf("\"%s\"\tid=%ld\t[", info->name, info->id);
}
printf("\"%s\"\tid=%ld\t[", info->name, info->id);
{
printf("%s\n", dev->name);
return;
{
printf("%s\n", dev->name);
return;
+ } else if (format == FORMAT_ID)
+ {
+ printf("%d\n", dev->deviceid);
+ return;
}
printf("%-40s\tid=%d\t[", dev->name, dev->deviceid);
}
printf("%-40s\tid=%d\t[", dev->name, dev->deviceid);
format = FORMAT_LONG;
else if (strcmp(argv[0], "--name-only") == 0)
format = FORMAT_NAME;
format = FORMAT_LONG;
else if (strcmp(argv[0], "--name-only") == 0)
format = FORMAT_NAME;
+ else if (strcmp(argv[0], "--id-only") == 0)
+ format = FORMAT_ID;
- "[--short || --long || --name-only] [<device name>...]",
+ "[--short || --long || --name-only || --id-only] [<device name>...]",