Skip to content

type: add explicit XKB support for UTF-8 text - #317

Open
timothee-klaus wants to merge 1 commit into
ReimuNotMoe:masterfrom
timothee-klaus:feature/unicode-accent-support
Open

type: add explicit XKB support for UTF-8 text#317
timothee-klaus wants to merge 1 commit into
ReimuNotMoe:masterfrom
timothee-klaus:feature/unicode-accent-support

Conversation

@timothee-klaus

Copy link
Copy Markdown

Summary

This adds an explicit XKB-aware mode to ydotool type while preserving the historical ASCII behavior by default.

When XKB options are supplied, all input characters, including ASCII characters, are resolved through the selected XKB keymap.

Motivation

ydotool type historically relies on a hard-coded US key table for ASCII input. This prevents explicit layout-aware key resolution and does not support general UTF-8 text.

The new implementation adds strict UTF-8 decoding and uses libxkbcommon to resolve directly representable Unicode characters into Linux input key sequences.

Related: #22

Changes

  • add strict streaming UTF-8 decoding;
  • add XKB-based Unicode-to-key-sequence resolution;
  • add explicit XKB configuration options;
  • preserve the existing ASCII fast path when no explicit XKB mode is requested;
  • resolve all characters through XKB when explicit XKB options are used;
  • report invalid UTF-8 and unrepresentable characters explicitly;
  • add tests for UTF-8 decoding, layouts, modifiers and regressions;
  • document the XKB behavior and compositor limitations.

Example

ydotool type \
  --xkb-layout fr \
  --xkb-variant latin9 \
  "Élève déjà à Lomé"

Compatibility

The historical ASCII behavior remains unchanged unless explicit XKB options are provided.

Limitations

  • the XKB options only configure key resolution inside the ydotool client;
  • they do not change the keymap assigned by the compositor to the virtual ydotoold device;
  • the compositor keymap must be compatible with the keymap used by ydotool;
  • libxkbcommon does not automatically read the active GNOME layout;
  • Compose and dead-key sequences are not supported;
  • characters that are not directly representable by the selected keymap produce an explicit error.

Validation

git diff --check

Passed with no output.

cmake -S . -B build -DBUILD_DOCS=OFF

Passed:

-- Version: v1.0.4-38-g708e96f
Systemd service file is going to be installed at /lib/systemd/system
-- Configuring done
-- Generating done
-- Build files have been written to: build
cmake --build build -j"$(nproc)"

Passed:

[ 15%] Built target ydotoold
[ 38%] Built target test_type_text
[100%] Built target ydotool
ctest --test-dir build --output-on-failure

Passed:

Test project build
    Start 1: type_text
1/1 Test #1: type_text ........................   Passed    0.04 sec

100% tests passed, 0 tests failed out of 1
cmake -S . -B build-docs -DBUILD_DOCS=ON

Passed:

-- Version: v1.0.4-38-g708e96f
Systemd service file is going to be installed at /usr/lib/systemd/user
-- Configuring done
-- Generating done
-- Build files have been written to: build-docs
cmake --build build-docs -j"$(nproc)"

Passed:

[  7%] Built target ydotool.1
[ 23%] Built target test_type_text
[ 30%] Built target ydotoold.8
[ 38%] Built target ydotoold
[100%] Built target ydotool

Copilot AI review requested due to automatic review settings July 7, 2026 19:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants