tools: add --replay-after and --once to libinput replay
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 3 Feb 2023 04:16:27 +0000 (14:16 +1000)
committerJosé Expósito <jose.exposito89@gmail.com>
Mon, 6 Feb 2023 18:02:58 +0000 (18:02 +0000)
For the cases where it's not possible to hit enter to start the replay
because e.g. we cannot change focus, etc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-replay.man
tools/libinput-replay.py

index dcae907c5786141c9116c678b7a5310978fac494..9eae92e110ec2c2556dd6494c926b46cfa933094 100644 (file)
@@ -15,6 +15,13 @@ simultaneously.
 .TP 8
 .B \-\-help
 Print help
+.TP 8
+.B \-\-once
+Only replay the recording once, then exit.
+.TP 8
+.B \-\-replay-after=s
+Replay the recording after waiting for s seconds. This replaces the default
+interactive prompt to start the replay.
 .SH NOTES
 .PP
 This tool replays events from a recording through the the kernel and is
index 63f662faa366e82e04964a1543fe62c1b6054e9d..1a8fe7003a0c240b702cced6867771d086d5e652 100755 (executable)
@@ -269,7 +269,10 @@ def loop(args, recording):
         return
 
     while True:
-        input("Hit enter to start replaying")
+        if args.replay_after >= 0:
+            time.sleep(args.replay_after)
+        else:
+            input("Hit enter to start replaying")
 
         processes = []
         for d in devices:
@@ -284,6 +287,9 @@ def loop(args, recording):
 
         del processes
 
+        if args.once:
+            break
+
 
 def create_device_quirk(device):
     try:
@@ -363,6 +369,18 @@ def main():
         type=str,
         help="Path to device recording",
     )
+    parser.add_argument(
+        "--replay-after",
+        type=int,
+        default=-1,
+        help="Automatically replay once after N seconds",
+    )
+    parser.add_argument(
+        "--once",
+        action="store_true",
+        default=False,
+        help="Stop and exit after one replay",
+    )
     parser.add_argument("--verbose", action="store_true")
     args = parser.parse_args()