Hyprland: clipboard sharing with Wine apps does not work in Hyprland. It's fine with Swaywm and other wayland WMs
As the title suggests, I cannot get clipboard sharing to work between wine applications and hyprland.
I’ve simplified the issue and can replicate easily using just notepad.exe.
Copying from notepad.exe running under Wine successfully goes to the Wayland WM clipboard.
Copying from Wayland / Hyprland does NOT go to the clipboard in Wine.
Clipboard is fine in both directions with swaywm (which is where I am migrating from). I am using the same setup - with copyq
- managing the clipboard in both places.
I have also been able to replicate the same results using the recommended / documented clipboard settings in the Hyprland Wiki:
exec-once = copyq --start-server
and separately,
exec-once = wl-paste --type text --watch cliphist store #Stores only text data
exec-once = wl-paste --type image --watch cliphist store #Stores only image data
The problem seems to only occur in Hyprland, which is why I raise this.
Is there a suggestion to help me troubleshoot root cause please?
Thank you!
Hyprland, built from branch at commit f27873a6f06dc2f87600edb890f3c38298bfb55f dirty ().
Tag: v0.25.0
flags: (if any)~```
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 14
- Comments: 34 (4 by maintainers)
I sent a PR to wlroots https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4359, which drops the restriction of unfocused xwayland apps to read clipboard. Pasting contents from native wayland to wine works with it.
An actual fix may be
wl-paste -t text -w xclip -selection clipboard
. This has fixed it for me in a proton game, and in Unity editor. This uses the actualxclip
, notwl-clipboard-x11
.@simonm can you please re-open this? the bug isn’t fixed, and “use a different wine” isn’t applicable for everyone
ive tried a couple of different configurations, at first it was just wl-clip-persist and it didnt work, so i tried getting a clipboard manager and syncing the primary and secondary and it didnt work. then i tried installing wl-clipboard-x11 which is a wrapper around xclip/xsel because i didnt have them, still didnt work. then i tried syncing the clipboards with wl-paste -pw wl-copy and copyq but it still doesnt work im trying too copy paste into the notepad that ships with wine, so its wine-wl’s notepad app. i cant copy paste into it, but i can copy from it, it will let me copy paste from wine too proton but not wayland too proton or wayland too wine
This hint helped me fix the issue I was having with Warframe, which now pastes properly using theforceinput
window rule:Not sure if this has side effects yet, but it works fine for my usecase. Hopefully that PR is merged so this doesn’t have to be worked around by the user.Edit: In the case of Warframe, this does not work as expected. I assumed it did due to restarting the game allowing pasting even without
forceinput
. I’ve taken to using thexclip
workaround instead.wl-paste -t text -w xclip -selection clipboard
does have some issues. It will start copying constantly if the copy source uses the X clipboard. So it is indeed just a workaround for now.Thanks! Far from perfect solution especially that it completely messed up hyprpm and I need to build split-monitor-workspaces by hand but got it working so I am fine for now. Hope a upstream solution will be found some day.
I have an aur package w/o the xwayland clipboard restriction of wlroots. Unfortunately, it won’t get upstreamed because wlroots maintainers don’t think dropping the restriction is the right thing to do
given that sway doesn’t have this problem, i assume it’s a small problem with a simple fix buried somewhere in the code. unfortunately i’m not familiar enough with either project to know how to approach it without help.
wl-paste -t text -w sh -c 'xclip -selection clipboard -o > /dev/null 2> /dev/null || xclip -selection clipboard'
fixes the infinite copying issue that occurs in X applications.Also, without the xclip workaround, I noticed that
xclip -selection clipboard -o
givesError: target STRING not available
on stderr when the copy is from a wayland application. It appears that the X clipboard gets cleared when copying from a wayland application, but does not receive the new thing that is copied.I think the reason the infinite copying occurs is that when
xclip
copies while an X application is focused, it gets forwarded to the wayland clipboard, which causeswl-paste -w
to trigger, causingxclip
to copy again, creating the loop. The new workaround prevents this by only copying withxclip
ifxclip
errors out trying to paste.Edit: the command is inconsistent. I now use
wl-paste -t text -w sh -c '[ "$(xclip -selection clipboard -o)" = "$(wl-paste -n)" ] || xclip -selection clipboard'
And funny that it doesn’t work all the time, I’m not sure where the problem is. I had some issues between termite and firefox which doesn’t exists anymore with this workaround, but between XWayland or Wine applications it’s a hit-and-miss.