summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-01-18 13:02:20 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-01-20 07:41:58 +1000
commit976c989af7978277061d0166d8e2a82cb8b1e795 (patch)
tree061ca479c005911113c733758085a86a28e3bfc9 /src
parentab90151162d39607e264e715a582e783e0da3c3a (diff)
Add --id-only flag for 'xinput list'.
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>
Diffstat (limited to 'src')
-rw-r--r--src/list.c13
-rw-r--r--src/xinput.c2
2 files changed, 13 insertions, 2 deletions
diff --git a/src/list.c b/src/list.c
index 0e6f9be..ca3c6bf 100644
--- a/src/list.c
+++ b/src/list.c
@@ -27,7 +27,8 @@
enum print_format {
FORMAT_SHORT,
FORMAT_LONG,
- FORMAT_NAME
+ FORMAT_NAME,
+ FORMAT_ID,
};
@@ -45,6 +46,10 @@ print_info(Display* dpy, XDeviceInfo *info, enum print_format format)
{
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);
@@ -203,6 +208,10 @@ print_info_xi2(Display* display, XIDeviceInfo *dev, enum print_format format)
{
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);
@@ -317,6 +326,8 @@ list(Display *display,
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;
arg_dev++;
}
diff --git a/src/xinput.c b/src/xinput.c
index 86c163e..a20f856 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -68,7 +68,7 @@ static entry drivers[] =
set_mode
},
{"list",
- "[--short || --long || --name-only] [<device name>...]",
+ "[--short || --long || --name-only || --id-only] [<device name>...]",
list
},
{"query-state",