feat: route press_key chords through the portal keyboard session#51
Conversation
On Wayland, press_key previously went straight to ydotool even when an XDG RemoteDesktop keyboard session was already active (the path type_text already uses). Plasma users therefore needed ydotoold and /dev/uinput solely for key combos. press_key now parses the chord into evdev codes (new key_chord helper, shared with the ydotool key_sequence encoding) and sends it through the portal via the existing press_keycode_chord when the chord policy prefers the portal: any Wayland session where a keyboard session is already cached (reusing granted consent even if ydotool is present), where ydotool is absent, or where the portal is forced via COMPUTER_USE_LINUX_FORCE_PORTAL_KEYBOARD. ydotool remains the fallback and COMPUTER_USE_LINUX_FORCE_YDOTOOL_KEYBOARD still pins it. Portal send failures clear the cached session and report the error explicitly. Closes #50.
There was a problem hiding this comment.
Code Review
This pull request introduces support for sending key chords through an active remote desktop portal keyboard session on Wayland, falling back to ydotool when unavailable. It refactors key parsing by introducing a key_chord helper to split modifiers and keycodes, updates key_sequence to leverage this helper, and adds corresponding unit tests. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Closes #50 (thanks @maxburto for the detailed report).
What
press_keypreviously parsed the chord and unconditionally invoked ydotool, even when an XDG RemoteDesktop keyboard session was already active — the same sessiontype_textalready obtains and uses. On Plasma Wayland this meant installingydotoold+/dev/uinputaccess solely for key combos.How
key_chordhelper parses a chord (Ctrl+Shift+P) into evdev modifier codes + key code;key_sequence(the ydotool encoding) is now a thin wrapper over it, so both backends share one parser and the key grammar stays identical.press_keysends the chord through the existingpress_keycode_chordportal call when the new chord policy prefers the portal, with the result message identifying the backend ("Action sent through the remote desktop portal.").should_prefer_portal_keyboard_for_chords): on any Wayland session — including Plasma, unlike the literal-text policy which routes KDE to the clipboard backend — the portal is used when a keyboard session is already cached (reusing the consent the user granted, even if ydotool is present), when ydotool is absent, or whenCOMPUTER_USE_LINUX_FORCE_PORTAL_KEYBOARDis set.COMPUTER_USE_LINUX_FORCE_YDOTOOL_KEYBOARDstill pins ydotool.type_textsemantics). If no session can be established, ydotool remains the fallback.Acceptance mapping (from #50)
press_key Ctrl+Sgoes through the portal. ✓ (policy prefers portal when ydotool socket is absent, and Plasma is no longer excluded for chords)Validation
cargo test --lib: 141 passed (addskey_chord_splits_modifiers_and_key).cargo fmt --check,cargo clippy --all-targets -- -D warnings: clean.