mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 18:30:06 +01:00
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>
This commit is contained in:
parent
056a5eb64a
commit
a1ba6186e7
1 changed files with 17 additions and 1 deletions
|
|
@ -1334,6 +1334,19 @@ open_output_file(struct record_context *ctx, bool is_prefix)
|
||||||
return true;
|
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
|
static int
|
||||||
mainloop(struct record_context *ctx)
|
mainloop(struct record_context *ctx)
|
||||||
{
|
{
|
||||||
|
|
@ -1393,7 +1406,7 @@ mainloop(struct record_context *ctx)
|
||||||
ctx->output_file);
|
ctx->output_file);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "recording to '%s'\n", ctx->output_file);
|
fprintf(stderr, "Recording to '%s'.\n", ctx->output_file);
|
||||||
|
|
||||||
print_header(ctx);
|
print_header(ctx);
|
||||||
if (autorestart)
|
if (autorestart)
|
||||||
|
|
@ -1465,6 +1478,9 @@ mainloop(struct record_context *ctx)
|
||||||
rc--;
|
rc--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->out_fd != STDOUT_FILENO)
|
||||||
|
print_progress_bar();
|
||||||
|
|
||||||
}
|
}
|
||||||
indent_pop(ctx); /* events: */
|
indent_pop(ctx); /* events: */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue