wrtype
A Rust implementation of wtype - xdotool type for Wayland.
Features
- Text Input: Type unicode characters
- Modifier Keys: Press/release modifiers (shift, capslock, ctrl, logo, win, alt, altgr)
- Named Keys: Press/release named keys using XKB key names
- Delays: Configurable delays between keystrokes and sleep commands
- Stdin Support: Read text from stdin for piped input
Usage
# Type unicode characters
# Press Ctrl+C
# Delay between keystrokes
# Read from stdin with delay
|
# Press and release the Left key
# Hold the Right key for 1000ms
Building
Using Nix (Recommended)
Using Cargo
Ensure you have the following system dependencies:
- libxkbcommon-dev
- wayland-dev
- wayland-protocols
Options
-M <MOD>: Press modifier (shift, capslock, ctrl, logo, win, alt, altgr)-m <MOD>: Release modifier-P <KEY>: Press key-p <KEY>: Release key-k <KEY>: Type (press and release) key-d <TIME>: Sleep for TIME milliseconds between keystrokes-s <TIME>: Sleep for TIME milliseconds before interpreting following options--stdin: Read text from stdin
Architecture
The implementation consists of several modules:
- Command Line Interface: Uses clap for argument parsing
- Wayland Protocol: Implements virtual keyboard protocol using wayland-client
- Keymap Generation: Dynamic XKB keymap generation for unicode support
- Command Execution: Sequentially executes typing commands with proper timing
Library Usage
wrtype can be used as a Rust library for programmatic text input and automation:
use ;
Add to your Cargo.toml:
[]
= { = "https://github.com/conneroisu/wrtype" }
Examples
The examples/ directory contains comprehensive examples showing different use cases:
Quick Start
# Run the interactive example runner
# Or run specific examples
Using just (if available)
# Quick start guide
# Run specific examples
# Development commands
Available Examples
- Basic Typing (
basic_typing.rs) - Simple text input with Unicode support - Shortcuts (
shortcuts.rs) - Common keyboard shortcuts and combinations - Stdin Processing (
stdin_processing.rs) - Reading and processing piped input - Advanced Sequences (
advanced_sequences.rs) - Complex automation workflows
Run any example with:
# or using nix
Compatibility
wrtype is compatible with the original C implementation of wtype and supports the same command-line interface and functionality.