gnome-shell-extension-clipboard-indicator icon indicating copy to clipboard operation
gnome-shell-extension-clipboard-indicator copied to clipboard

[WIP] Support for images

Open RuiGuilherme opened this issue 3 years ago • 27 comments

Features:

  • Change history size: MAX 2000 and MIN 2
  • Support to save images (Optional)
  • Image preview on menu https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator/pull/286/commits/d6475bf95cce05130b4460e3d920bcf08e038664
  • Support for image/png (Optional)
  • Support to file manager (Tested in Dolphin, Nautilus and Nemo) https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator/commit/7a97da53d0c25aedaf503d1cf2a4cc3831a60abc

Know issue:

  • Large images (9 mb or more) may not save. (8k wallpaper for example haha)
  • image/png only works with Mutter 41.3+ (patch mutter )

RuiGuilherme avatar Apr 16 '21 08:04 RuiGuilherme

Probably related: #112 #70 #222
#154 #21

RuiGuilherme avatar Apr 16 '21 08:04 RuiGuilherme

Hi :) Thank you for this, I hope you can make this work as this is a feature I personally have been waiting for.

I see you are serializing images as Base64 and save it inside the json, right? What do you think about saving the images on the file system, and just reference their path in the JSON?

Tudmotu avatar Apr 21 '21 11:04 Tudmotu

I see you are serializing images as Base64 and save it inside the json, right?

Yes, but for _addEntry() I use bytes because for some reason convert Base64 to Bytes inside Clipboard.set_content() costs me ~2 Seconds for small imagens.

What do you think about saving the images on the file system, and just reference their path in the JSON?

I will try using JSON, that should probably avoid the "throttling".

RuiGuilherme avatar Apr 21 '21 12:04 RuiGuilherme

commit bc45597 now save files inside .cache and JSON save only path...

I did several tests with and without the mutter patch... All works fine.

Fix:

  • 1mb images or more large can cause a "throttling".
  • many images in history also cause "throttling".
  • can cause delay on gnome start and restart

RuiGuilherme avatar Apr 24 '21 22:04 RuiGuilherme

https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator/pull/286/commits/7a97da53d0c25aedaf503d1cf2a4cc3831a60abc

1 case:

If you copy only text will work as expected, example:

Teste Line 1
Teste Line 2

Will save only the text in JSON;

2 case

If you copy two (or more) images in the file manager (Dolphin, Nautilus or Nemo), example:

/home/ruiguilherme/Pictures/imagem1.jpg
/home/ruiguilherme/Pictures/imagem2.png
+++

Will save both(or more) images if they exist... If not exist will save the path on JSON(1 case).

3 case

If you copy two(or more) images and a folder in the file manager (Dolphin, Nautilus or Nemo) , example:

/home/ruiguilherme/Pictures
/home/ruiguilherme/Pictures/imagem1.jpg
/home/ruiguilherme/Pictures/imagem2.png
+++

Will save the two images in the cache, however will be copied and saved the path's of the 3 items (similar to the first case).

RuiGuilherme avatar May 11 '21 15:05 RuiGuilherme

Hi @RuiGuilherme :) Is this still WIP?

Tudmotu avatar Jun 30 '21 07:06 Tudmotu

Yup, I need more testers... it works well on my i7 9750h but I don't have low-end spec to test possibles issues performance.

I will try to find someone available in some group related to GNOME to test.

RuiGuilherme avatar Jun 30 '21 15:06 RuiGuilherme

I gave this a spin, but I think there is a bug when copying regular text:

  1. With a fresh install/cache, copy some text
  2. View the Clipboard Indicator history via clicking top bar icon (drop-down)
  3. Copied text appears as a filepath, rather than the copied text itself

The filepath also appears to be incorrect: /home/duane/.cache/[email protected]/undefined

When I run journalctl /usr/bin/gnome-shell -f -o cat, I see the following error messages:

Error looking up permission: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for geolocation
JS ERROR: Gio.IOErrorEnum: Error opening file /home/duane/gnome-shell: No such file or directory
getImage@/home/duane/.local/share/gnome-shell/extensions/[email protected]/utils.js:43:17
_addEntry@/home/duane/.local/share/gnome-shell/extensions/[email protected]/extension.js:272:70
wrapper@resource:///org/gnome/gjs/modules/script/_legacy.js:83:27
_buildMenu/</<@/home/duane/.local/share/gnome-shell/extensions/[email protected]/extension.js:192:22
_buildMenu/<@/home/duane/.local/share/gnome-shell/extensions/[email protected]/extension.js:190:25
readRegistry/</<@/home/duane/.local/share/gnome-shell/extensions/[email protected]/utils.js:161:25

...

Registering session with GDM
JS ERROR: Error: Expected an object of type GBytes for argument 'bytes' but got type string
writerImage/<@/home/duane/.local/share/gnome-shell/extensions/[email protected]/utils.js:31:20

JS ERROR: TypeError: content is null
_refreshIndicator/</<@/home/duane/.local/share/gnome-shell/extensions/[email protected]/extension.js:519:21

UPDATE: I've made a PR (see below) that fixes these issues.

canadaduane avatar Aug 01 '21 23:08 canadaduane

I've made a PR to @RuiGuilherme's branch https://github.com/RuiGuilherme/gnome-shell-extension-clipboard-indicator/pull/3 that incorporates my suggested changes during code review above.

(My first time making a PR to a PR!)

canadaduane avatar Aug 02 '21 01:08 canadaduane

FWIW, this works for me now. Thanks @RuiGuilherme for all your work!

canadaduane avatar Aug 02 '21 15:08 canadaduane

@Tudmotu can this be merged in do you think?

canadaduane avatar Aug 12 '21 00:08 canadaduane

This is so good, why is it not merged yet :clap:

phamthainb avatar Sep 29 '21 07:09 phamthainb

Hi all, Am I missing something - when I right-click save image, it does not get added to the clipboard. Does this happen to you as well?

Tudmotu avatar Nov 14 '21 16:11 Tudmotu

Also, ctrl+v doesn't seem to paste images when I select them from the clipboard.

Tudmotu avatar Nov 14 '21 16:11 Tudmotu

I'm using GNOME 41 btw.

Tudmotu avatar Nov 14 '21 16:11 Tudmotu

Hi all, Am I missing something - when I right-click save image, it does not get added to the clipboard. Does this happen to you as well?

I thought some modification of version 41 caused the bugs, so I made a new branch to test and everything works. https://youtu.be/r23P8MXqSx0

https://github.com/RuiGuilherme/gnome-shell-extension-clipboard-indicator/tree/Gnome41

RuiGuilherme avatar Nov 14 '21 17:11 RuiGuilherme

Ok, interesting. Thanks :)

Tudmotu avatar Nov 14 '21 18:11 Tudmotu

I has to make some small changes due to conflicts and backwards compatibility, maybe I introduced a bug. Will look into it.

Tudmotu avatar Nov 14 '21 19:11 Tudmotu

Great features guys! I've been waiting for this! Just wanted to chime in to ask if saving the images on disk could pose a potential privacy issue. In case, for example, that an outside agent gained access to the folder you're storing the images in.

hyuri avatar Dec 19 '21 16:12 hyuri

Great features guys! I've been waiting for this! Just wanted to chime in to ask if saving the images on disk could pose a potential privacy issue. In case, for example, that an outside agent gained access to the folder you're storing the images in.

Yup, this can happen. However, this is not a specific problem of this feature, a malicious application could access JSON where the texts are stored and have access to all user history.

But I believe this is not exactly something to worry about, since a malicious application could have access to the clipboard.

RuiGuilherme avatar Dec 20 '21 12:12 RuiGuilherme

I am also looking forward to this one. Image support would be really cool! :)

ilazaridis avatar Dec 25 '21 13:12 ilazaridis

Just want to put this on the table - GPaste has supported images for a while now and it works quite well. It might be good to dig through their code for ideas?

mpetuska avatar Jan 09 '22 01:01 mpetuska

I just tried this out and several things seem broken:

  • My clipboard history was nuked, so backwards compat is not being handled properly
  • The settings, private mode, and clear history buttons disappeared
  • Copying an image from the web did not work (right click, copy image)
  • Copying an image from the file manager did work, but the aspect ratio is broken and the image is too small
  • After selecting a previously copied image, I am unable to paste it for whatever reason

Screenshot: image

SUPERCILEX avatar Jan 12 '22 20:01 SUPERCILEX

Thank you @SUPERCILEX for confirming the issues I encountered. I opened a new PR that includes backward-compat fixes: https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator/pull/334/files

To keep working on this, need to clone the feature/cache-images branch and to propose changes need to open a PR that points to feature/cache-images branch and not master.

Tudmotu avatar Jan 14 '22 10:01 Tudmotu

I just tried this out and several things seem broken:

* My clipboard history was nuked, so backwards compat is not being handled properly

* The settings, private mode, and clear history buttons disappeared

* Copying an image from the web did not work (right click, copy image)

* Copying an image from the file manager   _did  _ work, but the aspect ratio is broken and the image is too small

* After selecting a previously copied image, I am unable to paste it for whatever reason

Screenshot: image

Thank you. I'll work on the fixes. Did you use Branch for version 40+? https://github.com/RuiGuilherme/gnome-shell-extension-clipboard-indicator/tree/Gnome41

Captura de tela de 2022-01-14 11-42-51

RuiGuilherme avatar Jan 14 '22 14:01 RuiGuilherme

Why did this doesnt merged to master branch

rasyidrafi avatar Jun 23 '22 11:06 rasyidrafi

@rasyidrafi unfortunately this doesn't work.

Tudmotu avatar Aug 27 '22 19:08 Tudmotu

Closing. In the upcoming GNOME 45 version there will be image support (finally lmao). If anyone is currently testing using GNOME 45, I would appreciate if you could test this branch: https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator/tree/gnome45

Thank you @RuiGuilherme for this PR. It's been a long time coming. Much of the final implementation takes inspiration from your PR. Thank you :pray:

Tudmotu avatar Sep 09 '23 20:09 Tudmotu