summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2020-09-17 11:08:59 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2020-09-17 12:38:53 +1000
commit6e8aba9354f95522535b78f732e1ef20e1b4b0b2 (patch)
tree18e8c8ffbab24dead071dc01a864810965580459 /tools
parent2d641e6b7bcd4f35b111d739b15d00ae407cc1d5 (diff)
downloadlibinput-6e8aba9354f95522535b78f732e1ef20e1b4b0b2.tar.gz
tools/record: prefix the device list with a # character
Too many recordings end up with the device list at the top when users redirect stderr and stdout to the recordings file. This breaks yaml parsing and requires manual removal of the first few lines. Avoid this by prefixing the lines with a command character, this way the yaml stays correct. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/libinput-record.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index 7ea5a011..7efb0f6e 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -1956,12 +1956,16 @@ select_device(void)
char *device_path;
bool has_eaccess = false;
int available_devices = 0;
+ const char *prefix = "";
+
+ if (!isatty(STDERR_FILENO))
+ prefix = "# ";
ndev = scandir("/dev/input", &namelist, is_event_node, versionsort);
if (ndev <= 0)
return NULL;
- fprintf(stderr, "Available devices:\n");
+ fprintf(stderr, "%sAvailable devices:\n", prefix);
for (int i = 0; i < ndev; i++) {
struct libevdev *device;
char path[PATH_MAX];
@@ -1983,7 +1987,7 @@ select_device(void)
if (rc != 0)
continue;
- fprintf(stderr, "%s: %s\n", path, libevdev_get_name(device));
+ fprintf(stderr, "%s%s: %s\n", prefix, path, libevdev_get_name(device));
libevdev_free(device);
available_devices++;
}
@@ -2000,7 +2004,7 @@ select_device(void)
return NULL;
}
- fprintf(stderr, "Select the device event number: ");
+ fprintf(stderr, "%sSelect the device event number: ", prefix);
rc = scanf("%d", &selected_device);
if (rc != 1 || selected_device < 0)
@@ -2166,7 +2170,9 @@ mainloop(struct record_context *ctx)
ctx->output_file);
break;
}
- fprintf(stderr, "Recording to '%s'.\n", ctx->output_file);
+ fprintf(stderr, "%sRecording to '%s'.\n",
+ isatty(STDERR_FILENO) ? "" : "# ",
+ ctx->output_file);
print_header(ctx);
if (autorestart)