bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.56k stars 61 forks source link

wl-copy does not copy files under kwin #225

Open MrDrMcCoy opened 3 months ago

MrDrMcCoy commented 3 months ago

When I run wl-copy -pt image/gif < bueller.gif, it exits immediately, but does not copy anything into the clipboard. When I run wl-copy -fpt image/gif < bueller.gif, it hangs, and does not copy anything into the clipboard.

This is with version 2.2.1-1 (from Debian Trixie) under KDE 6.0.5.

Here are the outputs of WAYLAND_DEBUG=1 strace -vkinyyYo strace-wl-copy.txt wl-copy -fpt image/gif < bueller.gif: strace-wl-copy.txt WAYLAND_DEBUG.txt

bugaevc commented 3 months ago

Hi, thanks for the clear report! So from the logs you posted it looks like it does successfully copy your GIF into the clipboard. So how do you know that it "does not copy anything into the clipboard", what are the symptoms? Are you trying to paste it somewhere (where?) and it fails to paste? (If so, it's likely that the other app/client just doesn't support pasting image/gif.) Are you able to paste using wl-paste?

MrDrMcCoy commented 3 months ago

Symptoms are that after copying the file with wl-copy, Klipper does not show any new clipboard entries, and pasting gives me what was in there before. Doesn't matter where I paste. I've also tried with jpeg and png files, but get the same behavior.

I tried a new test just now: copying a plain text file. That successfully populates Klipper with a new entry and pasting works as expected. Seems this has something to do with binary data somehow.

MrDrMcCoy commented 3 months ago

I was mistaken. Copying an image from another app that I can paste from never makes an entry in Klipper, and wl-copy appears to fill the clipboard with nothing, so pasting does not give me what was in there last, it's just nothing.

The example apps I tried to paste into are Slack and Discord, which definitely accept clipboard image data when copied from other apps.

bugaevc commented 3 months ago

Could you try wl-paste --list-types, wl-paste > /tmp/pasted.gif?

MrDrMcCoy commented 3 months ago

The plot thickens.

3.2ms 11:11am 06/07 $ wl-copy < Nextcloud/reactions/and\ yet.jpeg
19.7ms 11:11am 06/07 $ wl-paste --list-types; wl-paste > /tmp/pasted.jpeg
image/jpeg
17.5ms 11:11am 06/07 $ kioclient exec /tmp/pasted.jpeg

This opens a valid jpeg image in Gwenview. Pasting that immediately into Discord/Slack does nothing. Re-copying the pasted image into Slack from Gwenview gives an "unsupported file type" message, while Discord populates an empty image. Pasting into LibreOffice Draw actually gives me the image, and re-copying it again from LibreOffice allows pasting into Slack/Discord successfully.

Maybe a few bytes of metadata are getting lost and reconstructed in this process somehow?