fix: route X11 keyboard input through xdotool XTEST (#58)#59
Merged
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
press_key and type_text used ydotool on X11, which injects raw evdev scancodes into a virtual uinput device. X11 then re-interprets those scancodes through the active XKB layout, so named keys and chords (Return, ctrl+a, ctrl+s) arrived as stray characters and literal text mangled symbols and digits (_ -> %, 1 -> +) even on a plain US layout. Prefer xdotool (XTEST) on non-Wayland sessions with DISPLAY set and the binary present; XTEST resolves keysyms against the live layout. The xdotool key grammar is validated through the existing key_chord parser so both backends accept exactly the same keys. ydotool remains the fallback when xdotool is absent or fails, and Wayland is untouched. doctor reports an xdotool input backend on X11. COMPUTER_USE_LINUX_FORCE_YDOTOOL_KEYBOARD=1 opts out; COMPUTER_USE_LINUX_FORCE_XDOTOOL_KEYBOARD=1 forces it on. Verified on a real Xvfb display driving an xterm through the MCP server: type_text "RAW_LINE1 _ 1 __ 11" landed byte-exact and press_key Return produced a real newline.
avifenesh
force-pushed
the
fix/x11-xtest-keyboard
branch
from
July 25, 2026 01:09
a518ebf to
4329489
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #58. Thanks @martin152 — the raw-
ydotool keyvs tool comparison in the report isolated this precisely.Root cause.
press_keyandtype_textboth went through ydotool on X11. ydotool writes raw evdev scancodes to a virtual uinput device; X11 then re-interprets those scancodes through the active XKB layout. So:press_key "Return"/ctrl+a/ctrl+s→ stray glyphs, no real key eventtype_text→ symbols and digits mangled (_→%,1→+), letters surviveThis is why raw
ydotool key 28:1 28:0worked in the reporter's test but the tool did not: the numeric-keycode path is fine at the uinput layer, but the scancode → layout translation is what breaks under X11.Fix. On non-Wayland sessions with
DISPLAYset andxdotoolpresent, both tools usexdotool(XTEST), which resolves keysyms against the live layout — what X11 clients actually expect.press_key→xdotool key --clearmodifiers <spec>(e.g.ctrl+a,Return,super+Return)type_text→xdotool type --clearmodifiers -- <text>key_chordparser, so both backends accept exactly the same key surface — no silent widening/narrowing, and the "never silently dropped" error is preserved.xdotoolis missing or the call fails.doctornow reports anxdotoolinput backend on X11.Escape hatches:
Test plan
xdotool_key_specaccepts exactly whatkey_chordacceptscargo fmt/cargo clippy -D warnings/ fullcargo testgreen:97+ xterm, driven through the MCP server over stdio):type_text "RAW_LINE1 _ 1 __ 11"→ landed byte-exact, no%/+manglingpress_key "Return"→ produced a real newline (confirmed by reading what the terminal received, not by AT-SPI)Action sent through xdotool (X11 XTEST).Note for @martin152: the
xdotoolpackage is now what makes X11 keyboard input correct — it's a soft dependency (ydotool still used as fallback), anddoctorwill list it once installed.Closes #58