Summary
On an X11 session, press_key does not produce the key it is asked for. Named keys like Return and chords like ctrl+a or ctrl+s end up inserting stray characters into the focused app instead of firing the real key. Pointer input, screenshots, window control and the AT-SPI tools all work well. This is specifically the keyboard-by-name path.
It took me a while to isolate, because my first guess (keyboard layout) turned out to be wrong. The short version: raw keycode injection through ydotool is fine, so the fault sits in how key names become events.
Environment
- computer-use-linux 0.4.1, installed via
./install.sh
- Linux Mint 22.3 (Ubuntu 24.04 "noble" base)
- Session: X11, Cinnamon (
X-Cinnamon), DISPLAY=:0
- Keyboard layout: US English. Confirmed in the tray. This matters, see below.
- ydotool 1.0.4 (official upstream binary),
ydotoold running as a user service, socket at /run/user/1000/.ydotool_socket
doctor input backends: abs_pointer, portal, ydotool; preferred = abs_pointer
doctor readiness: all flags true, blockers: []
What happens
Target is a plain xed window, focused by pid. Every result below is confirmed by screenshotting the window afterwards, not by reading a file or the AT-SPI tree (both of those gave me false readings early on, so I stopped trusting them).
type_text "HELLO FROM COMPUTER-USE-LINUX 12345" lands correctly. Letter typing works.
press_key "Return" gives no newline. It inserts two stray glyphs and the cursor stays on line 1.
press_key "ctrl+s" gives no save and no dialog. It inserts junk.
press_key "ctrl+a" gives no select-all. It inserts junk.
The isolating test
I ran the tool against raw ydotool on the same window, same session, and screenshotted each step.
Raw ydotool, numeric keycodes:
ydotool key 28:1 28:0 (Enter) produced a real newline. Works.
ydotool key 29:1 30:1 30:0 29:0 (Ctrl+A) selected the whole buffer. Works.
ydotool type "RAW_LINE1" came out as RAW%LINE+. Letters are fine, but _ became % and 1 became +.
The tool:
type_text "CUL_LINE1" came out as CUL%LINE+. Same mangling as raw ydotool type.
press_key "Return" gave stray chars, no newline.
press_key "ctrl+a" gave stray chars, no select-all.
Two things fall out of this.
First, ydotool key <numeric keycode> is reliable here. Enter and Ctrl+A both did exactly what they should. So uinput, the daemon, permissions and the injection layer are all healthy.
Second, press_key does not use that reliable path. If it were sending keycode 28 for Return, it would produce a newline like the raw call did. It doesn't. So the name-to-keycode step is where it breaks. My read is that named keys and chords get routed through the ydotool type path (or something that XKB then remaps), rather than through ydotool key with the correct numeric code. I have not read the source, so I can't point at the exact spot.
There is a related but separate wrinkle. ydotool type itself mangles some symbols and digits under X11 (_ to %, 1 to +), and type_text inherits it because it shares that path. Letters survive. It is intermittent rather than constant. My very first type_text with "12345" came out clean, a later one turned "1" into "+". This looks like the usual ydotool-on-X11 behaviour where injected keycodes get reinterpreted by the active XKB layout. The layout here is plain US, so this is not a non-US-layout issue.
Why I think this belongs here and not upstream in ydotool
The raw ydotool key path already works on X11. So a fix could be as small as having press_key translate names and chords into numeric keycodes and send them via ydotool key ..., instead of whatever currently produces stray characters. For the type_text symbol mangling, an X11 session might be better served by xdotool / XTEST, which respects the layout. ydotool is Wayland-first by design, and the README already flags X11 as best-effort, so this feels consistent with that.
Repro sketch
- X11 session, US layout.
- Open a text editor and focus it.
- Call
press_key with Return, then ctrl+a, then ctrl+s.
- Screenshot the window. Stray characters, no newline, no select, no save.
- For contrast, run
ydotool key 28:1 28:0 against the same window and watch a real newline appear.
I have annotated screenshots for each step and can attach them, or run any other combination you want tested. Thanks for the tool. Everything on the pointer, window and accessibility side has been solid.
Summary
On an X11 session,
press_keydoes not produce the key it is asked for. Named keys likeReturnand chords likectrl+aorctrl+send up inserting stray characters into the focused app instead of firing the real key. Pointer input, screenshots, window control and the AT-SPI tools all work well. This is specifically the keyboard-by-name path.It took me a while to isolate, because my first guess (keyboard layout) turned out to be wrong. The short version: raw keycode injection through ydotool is fine, so the fault sits in how key names become events.
Environment
./install.shX-Cinnamon),DISPLAY=:0ydotooldrunning as a user service, socket at/run/user/1000/.ydotool_socketdoctorinput backends:abs_pointer,portal,ydotool; preferred =abs_pointerdoctorreadiness: all flags true,blockers: []What happens
Target is a plain
xedwindow, focused by pid. Every result below is confirmed by screenshotting the window afterwards, not by reading a file or the AT-SPI tree (both of those gave me false readings early on, so I stopped trusting them).type_text "HELLO FROM COMPUTER-USE-LINUX 12345"lands correctly. Letter typing works.press_key "Return"gives no newline. It inserts two stray glyphs and the cursor stays on line 1.press_key "ctrl+s"gives no save and no dialog. It inserts junk.press_key "ctrl+a"gives no select-all. It inserts junk.The isolating test
I ran the tool against raw ydotool on the same window, same session, and screenshotted each step.
Raw ydotool, numeric keycodes:
ydotool key 28:1 28:0(Enter) produced a real newline. Works.ydotool key 29:1 30:1 30:0 29:0(Ctrl+A) selected the whole buffer. Works.ydotool type "RAW_LINE1"came out asRAW%LINE+. Letters are fine, but_became%and1became+.The tool:
type_text "CUL_LINE1"came out asCUL%LINE+. Same mangling as rawydotool type.press_key "Return"gave stray chars, no newline.press_key "ctrl+a"gave stray chars, no select-all.Two things fall out of this.
First,
ydotool key <numeric keycode>is reliable here. Enter and Ctrl+A both did exactly what they should. So uinput, the daemon, permissions and the injection layer are all healthy.Second,
press_keydoes not use that reliable path. If it were sending keycode 28 forReturn, it would produce a newline like the raw call did. It doesn't. So the name-to-keycode step is where it breaks. My read is that named keys and chords get routed through theydotool typepath (or something that XKB then remaps), rather than throughydotool keywith the correct numeric code. I have not read the source, so I can't point at the exact spot.There is a related but separate wrinkle.
ydotool typeitself mangles some symbols and digits under X11 (_to%,1to+), andtype_textinherits it because it shares that path. Letters survive. It is intermittent rather than constant. My very firsttype_textwith "12345" came out clean, a later one turned "1" into "+". This looks like the usual ydotool-on-X11 behaviour where injected keycodes get reinterpreted by the active XKB layout. The layout here is plain US, so this is not a non-US-layout issue.Why I think this belongs here and not upstream in ydotool
The raw
ydotool keypath already works on X11. So a fix could be as small as havingpress_keytranslate names and chords into numeric keycodes and send them viaydotool key ..., instead of whatever currently produces stray characters. For thetype_textsymbol mangling, an X11 session might be better served byxdotool/ XTEST, which respects the layout. ydotool is Wayland-first by design, and the README already flags X11 as best-effort, so this feels consistent with that.Repro sketch
press_keywithReturn, thenctrl+a, thenctrl+s.ydotool key 28:1 28:0against the same window and watch a real newline appear.I have annotated screenshots for each step and can attach them, or run any other combination you want tested. Thanks for the tool. Everything on the pointer, window and accessibility side has been solid.