Skip to content

Conversation

@dnouri
Copy link
Contributor

@dnouri dnouri commented Jul 13, 2025

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
Contributor

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
Copy link
Contributor Author

dnouri commented Jul 13, 2025

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 sst:dev Jul 14, 2025
@adamdotdevin
Copy link
Contributor

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

ndraiman pushed a commit to ndraiman/opencode that referenced this pull request Jul 15, 2025
Co-authored-by: Daniel Nouri <daniel@redhotcar>
achembarpu pushed a commit to achembarpu/opencode that referenced this pull request Aug 4, 2025
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