gnome-shell-extension-clipboard-indicator
gnome-shell-extension-clipboard-indicator copied to clipboard
[WIP] Support for images
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 )
Probably related:
#112
#70
#222
#154
#21
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?
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".
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
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).
Hi @RuiGuilherme :) Is this still WIP?
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.
I gave this a spin, but I think there is a bug when copying regular text:
- With a fresh install/cache, copy some text
- View the Clipboard Indicator history via clicking top bar icon (drop-down)
- 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.
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!)
FWIW, this works for me now. Thanks @RuiGuilherme for all your work!
@Tudmotu can this be merged in do you think?
This is so good, why is it not merged yet :clap:
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?
Also, ctrl+v doesn't seem to paste images when I select them from the clipboard.
I'm using GNOME 41 btw.
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
Ok, interesting. Thanks :)
I has to make some small changes due to conflicts and backwards compatibility, maybe I introduced a bug. Will look into it.
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.
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.
I am also looking forward to this one. Image support would be really cool! :)
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?
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:
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
.
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:
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
Why did this doesnt merged to master branch
@rasyidrafi unfortunately this doesn't work.
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: