fix(linux): prefer ydotool over xdotool on GNOME Wayland#202
Open
wrt54gl wants to merge 2 commits intoOpenWhispr:mainfrom
Open
fix(linux): prefer ydotool over xdotool on GNOME Wayland#202wrt54gl wants to merge 2 commits intoOpenWhispr:mainfrom
wrt54gl wants to merge 2 commits intoOpenWhispr:mainfrom
Conversation
On GNOME Wayland, xdotool can only interact with XWayland windows. When OpenWhispr (an Electron/XWayland app) tries to paste, xdotool targets OpenWhispr's own window instead of the focused native Wayland window, silently reports success, and prevents fallback to ydotool. This commit reorders the paste tool candidates on GNOME Wayland to try ydotool first. It also uses Ctrl+Shift+V with ydotool since terminal detection via xdotool/kdotool fails for native Wayland windows. Ctrl+Shift+V works correctly in both terminals (paste) and other apps (paste without formatting). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On GNOME Wayland, xdotool always returns OpenWhispr's own XWayland window instead of the actual focused window, making terminal detection fail. This caused ydotool to always send Ctrl+Shift+V (which doesn't work in apps like GNOME Text Editor) or always Ctrl+V (which doesn't work in terminals). Use the AT-SPI2 accessibility API to detect the active application, which works for both native Wayland and XWayland windows. This lets ydotool send the correct keystroke: Ctrl+Shift+V for terminals, Ctrl+V for everything else. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 tasks
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
Ctrl+Shift+Vfor detected terminals,Ctrl+Vfor everything elseProblem
On GNOME Wayland, xdotool can only interact with XWayland windows. When OpenWhispr (an Electron/XWayland app) attempts to paste into a native Wayland window (e.g. gnome-terminal, GNOME Text Editor), xdotool targets OpenWhispr's own XWayland window instead, silently reports success (exit code 0), and prevents fallback to ydotool.
Additionally, terminal detection via
xdotool getwindowclassnamefails on GNOME Wayland because xdotool always returns OpenWhispr's own window class — not the actual focused window. This causes the wrong paste shortcut to be sent.Solution
1. Prefer ydotool on GNOME Wayland
On GNOME Wayland (
isGnome && isWayland), ydotool is now tried before xdotool in the candidates array. ydotool works at the kernel input level and sends keystrokes to whatever window has compositor focus, regardless of whether it's a native Wayland or XWayland window.2. AT-SPI2 terminal detection
Since xdotool can't reliably detect the focused window on GNOME Wayland, terminal detection now uses the AT-SPI2 accessibility API via a lightweight Python script (~88ms). AT-SPI2 can see both native Wayland and XWayland windows and correctly identifies the active application (e.g.
org.gnome.Terminal).The detection flow on GNOME Wayland:
gnome-shell)Ctrl+Shift+V; otherwise → ydotool sendsCtrl+VFalls back to xdotool/kdotool detection if AT-SPI2 is unavailable.
3. Correct paste shortcuts
Ctrl+Shift+V(the standard terminal paste shortcut)Ctrl+VDependencies
python3withgi(PyGObject) and AT-SPI2 bindings — standard on GNOME desktop installationsydotool+ydotoolddaemon for keystroke injectionTest plan
Tested on Debian 13 (trixie) with GNOME Shell 48.7, NVIDIA RTX A400 (driver 550.x), Wayland session.
🤖 Generated with Claude Code