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.1-cp314-cp314-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.34+ ARM64

eitype-0.2.1-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.1-cp313-cp313-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

eitype-0.2.1-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.1-cp312-cp312-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ ARM64

eitype-0.2.1-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.1-cp311-cp311-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ ARM64

eitype-0.2.1-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.1-cp310-cp310-manylinux_2_34_aarch64.whl (1.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ ARM64

eitype-0.2.1-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.1-cp314-cp314-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp314-cp314-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 50e96606a08b2670e20452a07f33c87057f1ce3704d676ff6d4977cba1dd7af9
MD5 04526d811b57b8f3f7e2d0a5eae7885d
BLAKE2b-256 3260dca1399a50ee33bd42468127701ec692f3d7bc1898814bde66490a6c1447

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp314-cp314-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp314-cp314-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca1864cb419fab0ebcbcfedc0578dabad95611d807c5537a73880cdb6e504868
MD5 31eb287a154219414f19fe06799c02b7
BLAKE2b-256 34c81bde7d99041a2d749fc9a14e8157d7e05424dc6de02592bd71e27eb51673

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8ca96f5cec58b69496347fe14c0653dd100b01f6cf8d39c187afe1f6ab0a178e
MD5 6a0f736fa0c1ad0271b0c7f9a66445e5
BLAKE2b-256 c7d3627d30b1c52264883f3e25c3969b0336b9b6ffe867111c815095c85d591a

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e9d70de91812cf0ea4846b6430cf2f9263e32c9a9a64a578abb852f57c69136
MD5 9cf53f4a96fb23f77ad6c0d6817c856e
BLAKE2b-256 91ed7cf2fd8c6b791b3053644d3b03ba28e814e9281f5148b50ae425f386715a

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp312-cp312-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp312-cp312-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 c2c07b243fc3a95c9589ec47257098e9ca18340823abce4fc1f31cffb075d388
MD5 febfb1e1225a60b873be7597bb030053
BLAKE2b-256 c0a8daec48fc4a8842f7bdae1bc903e506e51f6ffb3bd3d8438e343042742ec4

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b90f27868e0a7a3548fdc1bc9890c222a8d1034326a741ae27d1b39af135a711
MD5 b77e3d05f89f1a9fb7cd3ac2998484d5
BLAKE2b-256 6e561ebb638f4f4afd3b7d51b480847d5b44004c5405268b6547f87ff99d3a4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp311-cp311-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp311-cp311-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 312e866e0606fd4e8b75f2cff68c9af3ea78c91ee63d9c29e86d0a8447a8904c
MD5 ae1a64228a6369575cd58a4f87a33d06
BLAKE2b-256 a747ba7df44edcf17b7a7c8b84974e90aa49d1146f1d6d0baf045a52fe2e364f

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85f17d0f4775946a51ee0ea02c30539ca3bd219b2597ddc4c6fe432a4f52a500
MD5 fc7354243bf29edfae183be2cf8c8f3d
BLAKE2b-256 056b86d9bf6af48c0e88be1fa80b0de4c56aefb8298dce7700d9af2bd194a74e

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp310-cp310-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp310-cp310-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4d98dcf81b1ccef9d91e0f2fcc831c398493ad0f1e605346cc98d1cac6928c6b
MD5 dd1d482622ab2ee6157cde8378366be0
BLAKE2b-256 3b3c7b22e6d09ab914b02b569451b6e4384b32b2171ecfcacc6a418d44acfe31

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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.1-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for eitype-0.2.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 86a43ba54f6bf5266b48eae363f3ea688906f7a0800b057a9eb69d013e7ac621
MD5 19a180f7b246aca515fa464e7cb840e4
BLAKE2b-256 55b655d2ae848d018e890a38df8114c793090ef92c2428c9d3b6aa001ed696de

See more details on using hashes here.

Provenance

The following attestation bundles were made for eitype-0.2.1-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