Skip to content

Fix clipboard on Wayland systems - #941

Merged
adamdotdevin merged 2 commits into
anomalyco:devfrom
dnouri:clipboard-wayland
Jul 14, 2025
Merged

adamdotdevin merged 2 commits into
anomalyco:devfrom
dnouri:clipboard-wayland

Conversation

@dnouri

@dnouri dnouri commented Jul 13, 2025

Copy link
Copy Markdown
Contributor

On Linux systems running a Wayland session, clipboard functionality could fail if both wl-clipboard and an X11-based tool like xsel were installed. The existing implementation did not prioritize the Wayland-native tool.

This change addresses the issue by:

  • Detecting a Wayland environment via the WAYLAND_DISPLAY variable.
  • Adjusting the tool preference order to prioritize wl-copy.
  • Correcting the tool name from wl-clipboard to wl-copy to ensure it is found in the system's PATH.

On Linux systems running a Wayland session, clipboard functionality
could fail if both `wl-clipboard` and an X11-based tool like `xsel`
were installed. The existing implementation did not prioritize the
Wayland-native tool.

This change addresses the issue by:

- Detecting a Wayland environment via the `WAYLAND_DISPLAY` variable.
- Adjusting the tool preference order to prioritize `wl-copy`.
- Correcting the tool name from `wl-clipboard` to `wl-copy` to ensure
it is found in the system's PATH.
@adamdotdevin

Copy link
Copy Markdown
Member

As a filthy macos user I have no way to test this atm, can you confirm this doesn't break paste? wl-paste still needed for paste right? Also, do you mind updating the docs?

@dnouri

dnouri commented Jul 13, 2025

Copy link
Copy Markdown
Contributor Author

Regarding MacOS, that's okay, nobody is perfect. ;-)

I updated the docs to clarify that wl-clipboard is preferred for systems running Wayland. You're right that wl-paste is also needed but I think it's fair to assume that wl-paste exists if wl-copy does.

Previously we were looking for a wl-clipboard binary, but that's the name of the package, and not a binary:

daniel@redhotcar:~$ which wl-clipboard
daniel@redhotcar:~$ which wl-copy
/usr/bin/wl-copy

@adamdotdevin
adamdotdevin merged commit 139d6e2 into anomalyco:dev Jul 14, 2025
@adamdotdevin

Copy link
Copy Markdown
Member

thanks a ton for this, please let me know if you see any other wayland issues in opencode!

bussard76 pushed a commit to bussard76/openwork that referenced this pull request May 12, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
Co-authored-by: Daniel Nouri <daniel@redhotcar>
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
Co-authored-by: Daniel Nouri <daniel@redhotcar>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants