wtype

repository·master·Indexed 19 days ago

https://github.com/atx/wtype

A Wayland-native command-line tool for simulating keyboard input using the virtual-keyboard protocol. It serves as a modern alternative to xdotool for Wayland compositors, allowing users to type strings, simulate specific key presses and releases via XKB symbol names, manage modifier keys (Shift, Ctrl, Alt, etc.), and control timing with keystroke and event stream delays.

Tokens
1.5K
Snippets
14
Records
14
Agent score
45%

What's inside wtype

  1. Build wtype from source

    master

    To build wtype, use the meson and ninja build systems. Follow these steps to configure, compile, and install the binary:

    meson build
    ninja -C build
    sudo ninja -C build install
  2. Use wtype to simulate keyboard input on Wayland

    master

    wtype is a command-line tool for Wayland that simulates keyboard input using the virtual-keyboard Wayland protocol. It functions similarly to xdotool type does for X11. You can use it to type strings of text or to simulate specific key presses and modifier combinations.

    wtype "Hello World"
  3. Use wtype to type text and control keys

    master

    The wtype CLI tool allows you to simulate keyboard input on Wayland by typing strings, pressing specific keys, or managing modifier keys (Shift, Ctrl, Alt, etc.).

    Basic Usage

    To type a simple string, pass it as an argument:

    wtype "hello world"

    Advanced Command Options

    Use flags to control the behavior of the typing sequence:

    • -d <ms>: Set a delay (in milliseconds) between each keystroke.
    • -s <ms>: Sleep for a specified number of milliseconds.
    • -k <keyname>: Press a specific key (uses XKB symbol names).
    • -P <keyname>: Press and hold a key.
    • -p <keyname>: Release a key.
    • -M <modifier>: Press a modifier key.
    • -m <modifier>: Release a modifier key.
    • --: Everything following -- is treated as raw text to be typed.
    • -: Read text from stdin.

    Modifier Names

    Supported modifier names (case-insensitive):

    • shift
    • capslock
    • ctrl
    • logo or win
    • alt
    • altgr
    wtype "hello world"
    wtype -d 100 "slow typing"
    wtype -s 500 "wait then type"
    wtype -M shift -k a -m shift
    wtype -- "text with special characters"
    wtype -
  4. Type text from stdin with wtype

    master

    You can pipe text into wtype to type it. Use the - flag to indicate that text should be read from standard input. This option can only appear once.

    echo "text from pipe" | wtype -
  5. Adjust keystroke delay with -d

    master

    The -d flag allows you to specify a delay (in milliseconds) between keystrokes. This delay can be applied to specific strings in the command line or to input coming from stdin.

    # delay of 0 when typing "foo", 120ms on "bar"
    wtype foo -d 120 bar
    
    # also applied on stdin
    echo everything | wtype -d 12 -
  6. Press and release modifiers with -M and -m

    master

    Use the -M flag to press a modifier key and the -m flag to release it. This is useful for simulating keyboard shortcuts like Ctrl+C.

    wtype -M ctrl c -m ctrl
  7. Insert delays into key event streams with -s

    master

    When performing complex sequences of key presses, use the -s flag to insert a delay (in milliseconds) into the stream of key events. This helps ensure the compositor processes the sequence correctly before the next event occurs.

    # Hold the Right key for 1000ms
    wtype -P right -s 1000 -p right
  8. Reference: wtype CLI flags and arguments

    master

    The following flags are used to configure the sequence of keyboard events sent by wtype.

    -d <ms>    Set delay between type keystrokes
    -s <ms>     Sleep for <ms> milliseconds
    -k <key>    Type a specific key (XKB name)
    -P <key>    Press a key
    -p <key>    Release a key
    -M <mod>    Press a modifier
    -m <mod>    Release a modifier
    --          Treat following arguments as raw text
    -           Read text from stdin
  9. Use modifier keys with wtype

    master

    You can simulate modifier keys using the -M (press) and -m (release) flags.

    Supported Modifiers: shift, capslock, ctrl, logo, win, alt, altgr.

    Note: Modifiers are automatically released once the wtype program terminates.

    wtype -M ctrl -k c