fix: improve clipboard paste on Wayland with ydotool and terminal detection #177
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 clipboard pasting on Wayland compositors (especially Unity) where wtype fails with "Compositor does not support the virtual keyboard protocol".
Changes
ydotool 0.1.x compatibility: Use key name syntax (
ctrl+v) instead of scan codes (29:1 47:1 47:0 29:0). The key name syntax works on both ydotool 0.1.x (Ubuntu packages) and 1.x versions.Prioritize ydotool on Wayland: When no target window ID is available, prefer ydotool over xdotool. xdotool reports success but can't reliably paste without window targeting on Wayland.
Improved terminal detection: Add fallbacks for detecting terminal emulators on Wayland where window class is unavailable:
This ensures terminals receive
Ctrl+Shift+Vinstead ofCtrl+V.Problem
On Wayland with Unity compositor:
wtypefails: "Compositor does not support the virtual keyboard protocol"xdotoolreports success but doesn't actually paste whentargetWindowIdis nullxdotoolWindowClassis null on WaylandTesting
Tested on Ubuntu 24.04 with:
Test plan
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 [email protected]