Skip to main content

Module daemon

Module daemon 

Source
Expand description

omni daemon — persistent-connection desktop keystroke replay (bd-1eefe5).

omni daemon runs as a lightweight service on a desktop, holds a persistent connection, and REPLAYS received InjectionCommands as local OS keystrokes — so omni send --daemon <addr> / omni cast --daemon <addr> can cast to desktops, not just phone/watch keyboards. Unlike tendril (a new SSH connection per keystroke) the client keeps one established connection.

The daemon speaks the same wire as the relay (crate::transport::relay): each line is either a token-gated cast ControlFrame or a bare InjectionCommand. Received commands are replayed through a pluggable Injector, so the connection/auth/loop is testable headless and real OS key synthesis is swappable. The same local port accepts subscribe clients; every accepted command is injected once and mirrored to all subscribers.

Structs§

BroadcastingInjector
Injector adapter used by relay-device mode: inject once, then mirror the received command to every local stream subscriber.
CaptureInjector
An injector that records every command it is asked to replay (for tests).
CommandBus
Bounded, non-blocking fan-out of commands received by the daemon.
DaemonOptions
Options for run_daemon.
LogInjector
An injector that only logs what it would replay — the safe default for headless hosts and --dry-run. Writes one NDJSON line per command to stderr.
OsascriptInjector
macOS injector via osascript (System Events).
RelayDeviceOptions
Options for run_relay_device.
WtypeInjector
Linux/Wayland injector via wtype.
XdotoolInjector
Linux/X11 injector: replay commands via xdotool.
YdotoolInjector
Linux/Wayland injector via ydotool (evdev keycodes).

Enums§

Backend
Which injector backend to use.
SessionEnd
Why a relay-device session ended.

Traits§

Injector
Replays an InjectionCommand as local OS keystrokes.

Functions§

current_platform
The platform string this build registers as (linux / macos / windows).
evdev_code
Linux evdev keycode for a semantic key / character (for ydotool key).
mac_key_code
macOS virtual key code for a semantic key name.
osascript_argvs
Build osascript -e <script> argv(s) (macOS). scroll is unsupported, and a combo must have exactly one non-modifier key.
relay_device_session
Register to a relay as a DEVICE over reader/writer, then drain bare InjectionCommand lines, replaying each via injector. One pass over a connected stream (no reconnect); returns how the session ended.
resolve_auto
Resolve the auto backend from the environment + available tools.
resolve_auto_with
Pure core of resolve_auto (OS / display / tool-presence injected for testability): macOS -> osascript; Wayland -> wtype then ydotool; X11 -> xdotool; else the safe log backend.
run_daemon
Run the daemon accept loop: each connection streams NDJSON; every received InjectionCommand (from a cast frame or a bare line) is replayed through injector. One thread per connection (mirrors relay::serve).
run_daemon_with_bus
Run the daemon with a caller-provided command bus. Relay-device mode uses this to share one bus between its outbound Helsinki connection and the local listener serving any number of omni listen clients.
run_relay_device
Run the relay-device loop: connect to relay_addr, register, drain + replay, and reconnect-with-backoff on a clean drop. Stops (returns Ok) on a relay rejection (token/config error) or when max_attempts is reached.
tool_on_path
Whether name resolves to a file on $PATH.
wtype_argvs
Build wtype argv(s) (Wayland). Reuses xdotool_keysym (wtype keys are XKB keysyms too). scroll is unsupported.
xdotool_argvs
Build the xdotool argv(s) for a command. A command usually maps to one invocation; scroll 0 maps to none.
xdotool_keysym
Map a semantic key name to an X11 keysym understood by xdotool key. Unknown names pass through unchanged (xdotool accepts many keysyms).
ydotool_argvs
Build ydotool argv(s) (Wayland/uinput). scroll is unsupported.