summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-01-18 12:55:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-01-20 07:41:58 +1000
commitab90151162d39607e264e715a582e783e0da3c3a (patch)
tree84a2480e811468d31c3579a317656e312b4f8464 /src
parentff1ff82438d35e6d68d1bf3b16bfc3520120247c (diff)
Add --name-only flag for 'xinput list'.
The default output of xinput list is hard to parse by scripts. Provide a --name-only option to print the device name 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.c31
-rw-r--r--src/xinput.c2
2 files changed, 26 insertions, 7 deletions
diff --git a/src/list.c b/src/list.c
index 9538a0a..0e6f9be 100644
--- a/src/list.c
+++ b/src/list.c
@@ -26,7 +26,8 @@
enum print_format {
FORMAT_SHORT,
- FORMAT_LONG
+ FORMAT_LONG,
+ FORMAT_NAME
};
@@ -40,6 +41,12 @@ print_info(Display* dpy, XDeviceInfo *info, enum print_format format)
XValuatorInfoPtr v;
XAxisInfoPtr a;
+ if (format == FORMAT_NAME)
+ {
+ printf("%s\n", info->name);
+ return;
+ }
+
printf("\"%s\"\tid=%ld\t[", info->name, info->id);
switch (info->use) {
@@ -192,6 +199,12 @@ print_classes_xi2(Display* display, XIAnyClassInfo **classes,
static void
print_info_xi2(Display* display, XIDeviceInfo *dev, enum print_format format)
{
+ if (format == FORMAT_NAME)
+ {
+ printf("%s\n", dev->name);
+ return;
+ }
+
printf("%-40s\tid=%d\t[", dev->name, dev->deviceid);
switch(dev->use)
{
@@ -246,10 +259,13 @@ list_xi2(Display *display,
dev = &info[i];
if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard)
{
- if (dev->use == XIMasterPointer)
- printf("⎡ ");
- else
- printf("⎣ ");
+ if (format == FORMAT_SHORT || format == FORMAT_LONG)
+ {
+ if (dev->use == XIMasterPointer)
+ printf("⎡ ");
+ else
+ printf("⎣ ");
+ }
print_info_xi2(display, dev, format);
for (j = 0; j < ndevices; j++)
@@ -259,7 +275,8 @@ list_xi2(Display *display,
if ((sd->use == XISlavePointer || sd->use == XISlaveKeyboard) &&
(sd->attachment == dev->deviceid))
{
- printf("%s ↳ ", dev->use == XIMasterPointer ? "⎜" : " ");
+ if (format == FORMAT_SHORT || format == FORMAT_LONG)
+ printf("%s ↳ ", dev->use == XIMasterPointer ? "⎜" : " ");
print_info_xi2(display, sd, format);
}
}
@@ -298,6 +315,8 @@ list(Display *display,
format = FORMAT_SHORT;
else if (strcmp(argv[0], "--long") == 0)
format = FORMAT_LONG;
+ else if (strcmp(argv[0], "--name-only") == 0)
+ format = FORMAT_NAME;
arg_dev++;
}
diff --git a/src/xinput.c b/src/xinput.c
index 9ca3832..86c163e 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -68,7 +68,7 @@ static entry drivers[] =
set_mode
},
{"list",
- "[--short || --long] [<device name>...]",
+ "[--short || --long || --name-only] [<device name>...]",
list
},
{"query-state",