savedra1 / clipse

Configurable TUI clipboard manager for Unix
MIT License
348 stars 14 forks source link

Not copying Images binaries from browsers #101

Closed AlephByte closed 4 months ago

AlephByte commented 4 months ago

Hello! I am not used to opening issues so I will try to give as much info as needed.

I am using NixOS with Hyprland/Wayland.

The clipboard manager clipse works great for text but when it comes to copying images, for example; from browsers like Floorp (Gecko/Firefox based) or Chrome, it does not work as intended.

For Floorp, it does copy the metadata: 2024-07-12-220030_hyprshot

And for Chrome it doesn´t register aa entry at all.

Strangely, when I was messing around with another clipboard manager cliphist, and 'loading' the image binary to the clipboard buffer, it does register a image-binary entry: 2024-07-12-220357_hyprshot

Nix Packages used:

kitty wl-clipboard clipse

hyprland.config:

exec-once = clipse -listen

windowrulev2 = float,class:(clipse)
windowrulev2 = size 1022 1052,class:(clipse)

bind = CTRL SHIFT, V, exec, kitty --class clipse -e bash -c 'clipse'
AlephByte commented 4 months ago

Additionally, image-preview show the images in a distorted way: 2024-07-12-220549_hyprshot

I don't know if this could be related to the fact i use a high resolution? 2880x1800

savedra1 commented 4 months ago

Hi @AlephByte :wave:

Thanks for raising this and for being so detailed in your explanation. First off, it looks like you are on version 1.0.0, upgrading to the latest Nix package 1.0.3 should slightly improve the image quality, though it will still appear a bit distorted due to having to be drawn using pixels in your kitty terminal.

RE the browser images, I'm not 100% sure why this only copies metadata/does not register anything, is the image pastable from your clipboard when it doesn't show in the history? Also, how are you "loading an image into the buffer?".

A workaround would also be to screenshot the browser image using a tool such as swappy and copy the image that way, though I can understand this may not be ideal.

AlephByte commented 4 months ago

is the image pastable from your clipboard when it doesn't show in the history? Yes, when I copy the image from Google-Chrome the image is pastable but there is no entry in the clipse hsitory, nor metadata or the image-binary.

Also, how are you "loading an image into the buffer?". With that I meant when I copy an image from browser, the image-binary is stored in cliphist and i select it from there. After doing that, clipse does register an entry with the image binary.

And yes, for screenshot apps like swappy or hyprshot the image binary is registered on clipse but I am not sure how good of an option that is because there might be a loss of quality/resolution doing so.

savedra1 commented 4 months ago

Thanks for clarifying @AlephByte. I've found the cause of this and I will look to implement a fix soon. I Will update you here when this has been implemented. thanks!

savedra1 commented 4 months ago

@AlephByte a fix has now been implemented in v1.0.5. The clipse -listen cmd will use the wl-clipboard api directly to extract images from the stdin. Note that when you copy an image from your browser after updating, you may find it now copies the binary and the metadata string. This is because wl-clipboard gets both bits of info from the stdin sometimes, but this will depend on the site/browser engine.

The updated Nix package should be available in a few days on the unstable branch. In the meantime you could also build the package.nix from source.

Hope this helps! I'll close this issue but feel free to reply if you still have problems with browser images after you've updated to 1.0.5.

Thanks again for raising this! :smile:

savedra1 commented 4 months ago

This will actually be updated to v1.0.7. Had to fix a quick bug I noticed from the previous release :grimacing:

Edit: last thing @AlephByte, drop the bash -e 'clipse' in favor of just bind = CTRL SHIFT, V, exec, kitty --class clipse -e clipse

This update causes a slight delay in the term environment initializing properly, that's the fix.