summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-03-15 08:44:19 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-03-19 14:24:15 +1000
commita1ba6186e70b102344ea6b17696b8ef7002ed6a2 (patch)
tree1f4014ad07cbeba45de6998116c94a68778e5484 /tools
parent056a5eb64a9b0e9701bda131954c06bf6cfb2487 (diff)
tools: libinput-record: print a progress bar when recording to a file
To let users know something is happening. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/libinput-record.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index d8ab4977..21954327 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -1334,6 +1334,19 @@ open_output_file(struct record_context *ctx, bool is_prefix)
return true;
}
+static inline void
+print_progress_bar(void)
+{
+ static uint8_t foo = 0;
+
+ if (!isatty(STDERR_FILENO))
+ return;
+
+ if (++foo > 20)
+ foo = 1;
+ fprintf(stderr, "\rReceiving events: [%*s%*s]", foo, "*", 21 - foo, " ");
+}
+
static int
mainloop(struct record_context *ctx)
{
@@ -1393,7 +1406,7 @@ mainloop(struct record_context *ctx)
ctx->output_file);
break;
}
- fprintf(stderr, "recording to '%s'\n", ctx->output_file);
+ fprintf(stderr, "Recording to '%s'.\n", ctx->output_file);
print_header(ctx);
if (autorestart)
@@ -1465,6 +1478,9 @@ mainloop(struct record_context *ctx)
rc--;
}
+ if (ctx->out_fd != STDOUT_FILENO)
+ print_progress_bar();
+
}
indent_pop(ctx); /* events: */