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)

Commits related to this issue

Most upvoted comments

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 actual xclip, not wl-clipboard-x11.

exec-once = wl-paste -t text -w xclip -selection clipboard

@simonm can you please re-open this? the bug isn’t fixed, and “use a different wine” isn’t applicable for everyone

Are the games usin the correct wine version in lutris or pure wine, I am also using a clipboard history retaining service clipmon git.sr.ht/~whynothugo/clipmon maybe using a clipboard retaining service is also a requirement.

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

restriction of unfocused xwayland apps to read clipboard.

This hint helped me fix the issue I was having with Warframe, which now pastes properly using the forceinput window rule:

forceinput, class:^steam_app_.*$

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 the xclip 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.

wl-paste -t text -w sh -c ‘v=$(cat); cmp -s <(xclip -selection clipboard -o) <<< “$v” || xclip -selection clipboard <<< “$v”’

This breaks coping images from/into xwayland apps at least on my system. When I copy an image from my web browser into another window I get the html of the image instead of the image itself. That works fine when wl-paste is not running or I use wl-paste only to puch stuff into cliphist. What would be best way to add cliphist store to that workaround? Thanks!

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

If so, isn’t this a trivial one-line fix? 🤔

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 gives Error: 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 causes wl-paste -w to trigger, causing xclip to copy again, creating the loop. The new workaround prevents this by only copying with xclip if xclip 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.