Skip to main content

Crate wdotool

Crate wdotool 

Source
Expand description

Library half of the wdotool binary. The thin main.rs wires argv → cli::Clidispatch, but everything testable lives here so integration tests in tests/ can drive dispatch against a mock backend without spawning a subprocess.

The two public entry points worth knowing:

  • dispatch runs a parsed Command against an arbitrary Backend, writing all human-readable output to the writers in DispatchCtx. It returns an ExitCode — the binary translates non-zero into process::exit, tests just assert on it.
  • SearchFilters is exposed so the existing search unit tests can keep their friendly module-private feel without re-deriving the filter logic.

Re-exports§

pub use cli::Cli;
pub use cli::Command;

Modules§

cli
diag
wdotool diag: environment + backend availability report.
record
wdotool record — capture user input until Ctrl-C (or --max-duration elapses) and write the events as JSON.
replay
wdotool replay <file> — read a captured RecEvent trace and dispatch each event through the active backend, reproducing the original timing.

Structs§

DispatchCtx
Output sinks + environment passed to dispatch. The binary fills these with io::stdout() / io::stderr(); tests fill them with Vec<u8> so they can assert on captured output.
ExitCode
Wraps a process exit status. 0 is success; non-zero is reserved for the xdotool-compatible “no match / unsupported on this backend” signals (search with no results, getmouselocation on a send-only backend, getwindow* with a missing field). dispatch returns this instead of calling process::exit directly so tests can run inside the same process.
SearchFilters
Compiled search predicates. Built once per wdotool search call and then applied to each window. Holding the regex(es) here avoids recompiling per-window.
SearchFlags
Inputs to SearchFilters::compile; mirrors the CLI flags so the filter compilation is testable without round-tripping through clap.

Functions§

dispatch
Run a parsed command against a backend. Returns a structured exit code instead of terminating the process; the binary calls process::exit on non-zero, tests assert directly.
init_tracing