Crate wrtype

Source
Expand description

§wrtype - Rust implementation of wtype for Wayland

This crate provides a library interface for programmatically typing text and sending key events through the Wayland virtual keyboard protocol. It’s designed as a Rust alternative to wtype/xdotool for Wayland compositors.

§Features

  • Type arbitrary Unicode text through Wayland virtual keyboard
  • Press and release individual keys and modifiers
  • Support for complex key sequences with timing control
  • Dynamic XKB keymap generation for Unicode characters
  • Compatible with any Wayland compositor supporting virtual-keyboard protocol

§Basic Usage

use wrtype::{WrtypeClient, Command};
use std::time::Duration;

// Create a client and connect to Wayland
let mut client = WrtypeClient::new()?;

// Type some text
client.type_text("Hello, Wayland!")?;

// Execute a key sequence
let commands = vec![
    Command::KeyPress("ctrl".to_string()),
    Command::KeyPress("c".to_string()),
    Command::KeyRelease("c".to_string()),
    Command::KeyRelease("ctrl".to_string()),
];
client.execute_commands(commands)?;

Re-exports§

pub use executor::CommandExecutor;
pub use keymap::KeymapBuilder;
pub use wayland::connect_wayland;
pub use wayland::WaylandState;

Modules§

executor
keymap
wayland

Structs§

WrtypeClient
High-level client interface for wrtype functionality

Enums§

Command
Internal command representation after parsing command-line arguments. Each command represents a single action to be executed in sequence.
Modifier
Modifier keys with their corresponding bit values for Wayland protocol. These values match the modifier mask constants used in XKB and Wayland.