Skip to main content

Python bindings for eitype - type text on Wayland using the Emulated Input (EI) protocol

Project description

eitype

A library and CLI tool for typing text using the Emulated Input (EI) protocol on Wayland.

Features

  • Type text using the EI (Emulated Input) protocol
  • Support for special keys (enter, tab, escape, arrows, function keys, etc.)
  • Support for modifier keys (shift, ctrl, alt, super)
  • XDG RemoteDesktop portal support with session persistence
  • Direct socket connection support
  • Configurable delay between key events
  • Keyboard layout configuration via CLI or environment variables
  • Python bindings for use in Python applications
  • Rust library for integration into other Rust projects

Installation

Using pixi (recommended)

Pixi handles all dependencies (including libxkbcommon) automatically:

# Build and install Python bindings
pixi run build

# Install CLI
pixi run install-cli

# Run tests
pixi run test

Manual Installation

System Dependencies

If not using pixi, install the required system libraries first:

Distribution Command
Debian/Ubuntu sudo apt install libxkbcommon-dev
Fedora/RHEL sudo dnf install libxkbcommon-devel
Arch Linux sudo pacman -S libxkbcommon
openSUSE sudo zypper install libxkbcommon-devel

CLI

cargo install --path .

Python

pip install maturin
maturin develop --features python

Usage

# Type text (uses XDG RemoteDesktop portal by default)
eitype "Hello, World!"

# Type with delay between keys (10ms)
eitype -d 10 "Slow typing..."

# Press special keys
eitype -k return
eitype -k tab
eitype -k escape

# Hold modifier while typing
eitype -M ctrl c  # Ctrl+C

# Press and release a modifier
eitype -P shift

# Multiple texts
eitype "First line" -k return "Second line"

# Verbose output
eitype -v "Debug mode"
eitype -vv "More debug"

Connection Methods

XDG RemoteDesktop Portal (Default)

By default, eitype connects via the XDG RemoteDesktop portal. This works with desktop environments that support it (GNOME, KDE, etc.).

eitype "Hello"

Session Persistence

eitype automatically saves a session token to avoid the authorization dialog on subsequent runs. The token is stored at ~/.cache/eitype/restore_token.

  • First run: Shows the authorization dialog, saves token for future use
  • Subsequent runs: Uses saved token, no dialog needed
  • Token expiration: If the token becomes invalid, a new dialog will appear

To force a new authorization dialog (clear the saved token):

eitype --reset-token "Hello"

Direct Socket

Use the -s flag to specify a socket path, or set the LIBEI_SOCKET environment variable to bypass the portal:

eitype -s /path/to/ei/socket "Hello"
# or
export LIBEI_SOCKET=eis-0
eitype "Hello"

Special Keys

Supported special key names (case-insensitive):

  • escape, esc
  • return, enter
  • tab
  • backspace
  • delete
  • insert
  • home, end
  • pageup, pagedown
  • up, down, left, right
  • f1 through f12
  • space
  • capslock, numlock, scrolllock
  • print, printscreen
  • pause, menu

Modifier Keys

Supported modifier names (case-insensitive):

  • shift, lshift, rshift
  • ctrl, control, lctrl, rctrl
  • alt, lalt, ralt, altgr
  • super, meta, win, lsuper, rsuper

Keyboard Layout

eitype uses XKB for keyboard layout handling. The keymap is determined in the following order:

  1. EI server keymap - If the EI server provides a keymap, it is used automatically
  2. CLI/environment configuration - If no server keymap, uses specified layout
  3. System default - Falls back to the system's default XKB configuration

CLI Options

# Use German keyboard layout
eitype -l de "Hallo Welt"

# Use US Dvorak layout
eitype -l us --variant dvorak "Hello"

# Full XKB configuration
eitype -l us --variant dvorak --model pc104 --options "ctrl:nocaps" "Hello"

# Select a specific layout index when multiple layouts are available
eitype --layout-index 1 "Hello"

Multi-Layout Keymaps

When the EI server provides a keymap with multiple layouts (e.g., Dvorak + QWERTY), eitype uses layout index 0 by default. This is typically correct since layout 0 is the first/active layout.

If you need to use a different layout, specify it with --layout-index:

# Use the second layout (index 1)
eitype --layout-index 1 "Hello"

Use -vv to see all available layouts in the keymap.

Environment Variables

You can also set keyboard layout via environment variables (CLI options take precedence):

  • XKB_DEFAULT_LAYOUT - Keyboard layout (e.g., "us", "de", "fr")
  • XKB_DEFAULT_VARIANT - Layout variant (e.g., "dvorak", "colemak", "nodeadkeys")
  • XKB_DEFAULT_MODEL - Keyboard model (e.g., "pc104", "pc105")
  • XKB_DEFAULT_OPTIONS - XKB options (e.g., "ctrl:nocaps")
  • XKB_DEFAULT_RULES - XKB rules file
# Set German layout via environment
export XKB_DEFAULT_LAYOUT=de
eitype "Hallo"

# Override with CLI
XKB_DEFAULT_LAYOUT=de eitype -l fr "Bonjour"  # Uses French layout

Python Usage

from eitype import EiType, EiTypeConfig

# Simple connection via portal
typer = EiType.connect_portal()
typer.type_text("Hello from Python!")
typer.press_key("Return")

# With custom configuration
config = EiTypeConfig(layout="de", delay_ms=10)
typer = EiType.connect_portal(config)
typer.type_text("Hallo Welt!")

# Modifier keys
typer.hold_modifier("ctrl")
typer.press_key("c")
typer.release_modifiers()

Token Persistence (for long-running apps)

For applications that run continuously (like voice typing tools), you can save and reuse the portal authorization token:

from eitype import EiType

# First run - will show authorization dialog
typer, token = EiType.connect_portal_with_token()
if token:
    save_to_config(token)  # Save for next time

# Subsequent runs - no dialog needed
saved_token = load_from_config()
typer, _ = EiType.connect_portal_with_token(saved_token)
typer.type_text("No dialog this time!")

Rust Library Usage

Add to your Cargo.toml:

[dependencies]
eitype = { path = "../eitype" }  # or from crates.io when published
use eitype::{EiType, EiTypeConfig, EiTypeError};

fn main() -> Result<(), EiTypeError> {
    // Connect via portal
    let mut typer = EiType::connect_portal(EiTypeConfig::default())?;

    // Type text
    typer.type_text("Hello from Rust!")?;
    typer.press_key("Return")?;

    // With modifiers
    typer.hold_modifier("ctrl")?;
    typer.press_key("c")?;
    typer.release_modifiers()?;

    Ok(())
}

Development

# Set up dev environment with pre-commit hooks
pixi run -e dev install-hooks

# Run linting (cargo fmt + clippy)
pixi run -e dev lint

Requirements

  • Rust 1.70+
  • Python 3.10+ (only for Python bindings)
  • libxkbcommon (handled automatically by pixi, or install manually)

License

Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

eitype-0.2.0-cp314-cp314-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

eitype-0.2.0-cp314-cp314-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64

eitype-0.2.0-cp313-cp313-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

eitype-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

eitype-0.2.0-cp312-cp312-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

eitype-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

eitype-0.2.0-cp311-cp311-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

eitype-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

eitype-0.2.0-cp310-cp310-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

eitype-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

File details

Details for the file eitype-0.2.0-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 ba1d5a5a227555caf7cff58b69bb1dd1d9a836ceee1f1cd1f939c4a111f22a39
MD5 8b767cc2658b78e1e754d81a47d5b747
BLAKE2b-256 c5418b759c277151e260346eecca4b8de9863152e526429ee44a40ef52daaefc

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp314-cp314-manylinux_2_34_aarch64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6df1d868e560153306a6841e70750fdbcb1c1feec7a233ce94e507f1429f701d
MD5 cc58e07d345e5442c2b688c8a238738d
BLAKE2b-256 69062194afa23b9a05af630fca8507f36e7a9b569857d6bdbf1b62436a70cd07

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp314-cp314-manylinux_2_28_x86_64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4356048b8faa0a91be017150884a627f70234c88c85adaf4977886fcb157074e
MD5 d43398712677ba24342be294bc0a1c70
BLAKE2b-256 8ccd9a268788419bbd2ab7a4f4a8909ddefdb0717ca5d727b0bbb670052ad10e

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp313-cp313-manylinux_2_34_aarch64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 03af01e8d50f5ba958ed282d1e2deb6aa57df717313776807409d3da5ed73362
MD5 eed44d6d195101f272ff4e83eef829eb
BLAKE2b-256 5996a3480adccc998ff4a86a53711765af0874edc0ab27f61982000df7a71f1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp313-cp313-manylinux_2_28_x86_64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 742433757e6c6534210bce81c964ca7dcc442493cd7e93a5dab7ad8fedf5dda6
MD5 c5ba2139990b23187c8121e66ba5351e
BLAKE2b-256 fec2e057b059fdd1fced0304cdea48f8f1cfc9299795c2430ce6fe9fdd1e72b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp312-cp312-manylinux_2_34_aarch64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a32f137b29aa167cf0c12d4d293592793ecea50bf8229777a938045196925d3b
MD5 8d6cb8700a35363634fee4be414078bd
BLAKE2b-256 66d11e6e288979068eda88cd948c91355561b78446da7aa580e159f9154ef369

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp312-cp312-manylinux_2_28_x86_64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 7a3a932686c7e745df207669907e245d899022714bb2aa8901410b5103e48c8d
MD5 e23ad155e3e0127933a03f2877fdbd90
BLAKE2b-256 769925f5960e604c33e3730184e238d0d87f6e8c6b5ab6834a3a5627651e2466

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp311-cp311-manylinux_2_34_aarch64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 51d6ffd865cc23ec6a402aee2076ad5e522dd9d715ad575442004ea3ff58b350
MD5 79fe9425324d8c698cc83b4c715311b0
BLAKE2b-256 dac82488b564e427e237c231b21a0d940fea248699cea71ae85367c5f878d322

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 d46015a528a3b058740fd0d478d3102a38f9e10853027ac5940035bc5ff3bded
MD5 81b4c70938f0d85422c1846c4cc141b8
BLAKE2b-256 41477f1ec43cd9314ffeb37bba96290f7364e8672eda8824ee9cb2462d86dbb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp310-cp310-manylinux_2_34_aarch64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eitype-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5da7edf03eb547a416b3a2b28368dc257448ef4eedb70ff26dac312753ac96f
MD5 8c3d4cc6e4a6b1537bd44af4ba087d23
BLAKE2b-256 d4d8efaa5142121f734c8242b87542a51117b88038149bd2809545b166af1b66

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl:

Publisher: release.yaml on Adam-D-Lewis/eitype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page