Products › lamco-dbus-tools › Docs

Record a dbusdo run and play it back as a script

Record a dbusdo run and play it back: Save a chain of D-Bus commands with --record, replay it at any speed, convert it to a script, and write scripts by hand.

Describes version 0.4.1. In this version the commands a chain can hold are the ones that shape it (pause, retry, soft), so what's recorded is timing. The same steps record and replay calls on a bus once those commands exist.

What's needed

dbusdo. No bus, no privilege. Layer: None.

Record a run

Add --record to any chain:

$ dbusdo --record morning.dbusdo pause 0.2 soft retry 2 pause 0.1
$ cat morning.dbusdo
# dbusdo recording, version 1
@0.000 pause 0.2
@0.200 soft retry 2 pause 0.1

Each line is a command with its modifiers and the moment it started.

Play it back

$ dbusdo -v play morning.dbusdo
pause 0.2: ok in 0.200 s
pause 0.1: ok in 0.100 s
play morning.dbusdo: ok in 0.300 s

A number after the file is a speed. dbusdo play morning.dbusdo 2 plays it twice as fast.

Turn it into a script you can edit

$ dbusdo convert morning.dbusdo morning.dbusdo-script
$ cat morning.dbusdo-script
# dbusdo script, from morning.dbusdo
pause 0.2
soft retry 2 pause 0.1
$ dbusdo run morning.dbusdo-script

A script has no times. Each line runs when the one before it has ended.

Write a script by hand

# setup.dbusdo-script
pause 1
soft retry 3 pause "{env:WAIT}"

{env:WAIT} is replaced with the environment variable WAIT when the script is read.

What can go wrong

  • ...: The name ends in neither .dbusdo (a recording) nor .dbusdo-script (a script): convert reads the direction from the two names.
  • <file> line 3 failed: The chain on that line failed. Its own message is on the line above.
  • {env:NAME}: The variable isn't set: Set it, or take it out of the script.
  • a script or a recording can't run another: A file can't hold run, play or session.

The whole run is under --timeout, 30 seconds unless set. For a long recording, set it higher or to 0.