Comments (22)
Hi @JPvRiel :) Thanks for this and the other comments!
An in-memory cache shouldn't be hard to implement. After all, it's just a JSON, no matter if in-memory or not. Writing to tmpfs is an interesting idea, and if possible with a non-privileged user, might work. If not, we can store the JSON in memory instead of on file (though this might not persist when extension is reloaded).
This can be an option in the settings.
Any of you like to try implementing this? I'm not sure when will i have time to do that, and would appreciate help :)
from gnome-shell-extension-clipboard-indicator.
I think it's very interesting too.
I want to pay attention to something : when you lock the screen of gnome, all extensions are closed and when you open your session again, all extensions are reloaded...so, this solution must delete cache not only after a reboot.
I don't know if it's possible to distinguish reboot and lock/open-the-same-session-again. If it is, it can be good to investigate, if not, the new option will be necessary a hard option (that I will use anyway^^).
from gnome-shell-extension-clipboard-indicator.
Nice! Awesome job! π
As far as I can see, you figured out everything, and it looks good.
Only issue I see is that in line 166 you use Fields.CACHE_FILE_DISABLE
but in line 17 you set the variable name to Fields.DISABLE_CACHE_FILE
.
You see the DISABLE
part is not in the same place. Maybe fixing that will solve the issue? Please let me know if it doesn't fix it, I will try to help more.
Definitely, writing gnome extensions is one of the most difficult things I ever did π No documentation, clumsy development workflow, errors are hidden in journal, no testing, etc..
Thanks for helping out!
Also, can you please open a PR already? Even if this doesn't fix the issues completely, it's more convenient to look at it through the pull request UI.
from gnome-shell-extension-clipboard-indicator.
Thanks for the idea! π
I'm not sure how to do that, though. I mean, I don't know how to listen to the shutdown signal.
Maybe somewhere in https://git.gnome.org/browse/gnome-shell/tree/js/misc
If anyone has any idea, it will be welcomed :)
I'll also look around a bit more.
from gnome-shell-extension-clipboard-indicator.
I've done investigations and finally found this https://github.com/farseerfc/systemd-shutdown-diagnose. It's a really good example.
The idea is to start a service at boot and when the service is stopped (basically shutdown and reboot), a shell script is called. Two files are needed like those that I've started to fill.
/usr/lib/systemd/system/shutdown-clipboard-indicator.service :
[Unit]
Description= A service to execute clear-at-shutdown-clipboard-indicator at shutdown
[Service]
Type=idle
RemainAfterExit=yes
ExecStart=/usr/bin/true
ExecStop=/usr/bin/clear-at-shutdown-clipboard-indicator
[Install]
WantedBy=default.target
/usr/bin/clear-at-shutdown-clipboard-indicator :
#!/bin/bash
/*
* Code here cleaning of history
*/
I hope I don't make mistakes because I don't know how to test it on my pc ("compile" and "make" are still weird for me).
from gnome-shell-extension-clipboard-indicator.
Nice idea! π But unfortunately I don't think we can do something like this:
- I'm pretty sure GNOME extensions can't add scripts to the systemd path.
- Even though systemd is very popular, it is not the only init system out there.
I would guess that there is some way of listening to a "logout" signal using the GNOME shell APIs. For example, seems like we can listen to a "PrepareForSleep" signal via the loginManager
module:
https://github.com/GNOME/gnome-shell/blob/master/js/misc/loginManager.js#L32
Or to to the "ConfirmedShutdown/Login/Reboot" signal in the endSessionDialog
module:
https://github.com/GNOME/gnome-shell/blob/695bfb96160033be55cfb5ac41c121998f98c328/js/ui/endSessionDialog.js#L57
Both don't give us what we want.
A simple option is to remove history in the .disable()
callabck, but that one is called in all sorts of occasions, and I'm not sure when exactly. If it's called on every screen-lock, I think it's not what we're looking for.
from gnome-shell-extension-clipboard-indicator.
I don't know those APIs, sorry.
The other solution is to delete history when the module is initiate at boot, it's could be very simple, no?
from gnome-shell-extension-clipboard-indicator.
@freeroot. see #46 (comment) ;-)
Basically, you can have what you've asked for by storing your clipboard history in RAM! A user level systemd unit. Instead of going onto disk (and available at next boot), it's in a tmpfs.
@Tudmotu , I get and agree that systemd isn't the only init system. The above is just a hack until we get around to having an in-memory cache option, which would be more secure than using tmpfs which all apps for the given user can read.
from gnome-shell-extension-clipboard-indicator.
@freeroot @Tudmotu I've done the tempfs thing with systemd for the logged in user. See:
It does work across shell extension reloads. Nevertheless, it's a work around for now. As commented before, gnome-shell extensions probably don't get to install user level systemd units.
tmpfs is an option, but remember, the X server / Linux desktop security model is really poor and all apps running under the same current user can read that file even if stored in tmpfs, hence I'd like the option of using an in memory json object rather than tmpfs.
from gnome-shell-extension-clipboard-indicator.
Hi,
Quick and dirty fix on my laptop : a small startup script to put with ln -s
the ~/.cache/[email protected]
in /dev/shm
(tmpfs)
But π for a new option "In memory only"
from gnome-shell-extension-clipboard-indicator.
Hi,
If this is too difficult to implement, what about an option to clear the clipboard at a certain interval like every day?
from gnome-shell-extension-clipboard-indicator.
"In memory" storage should not be too difficult to implement - add a boolean setting, and check its value before writing to the cache file (here).
from gnome-shell-extension-clipboard-indicator.
should not be too difficult to implement - add a boolean setting
@Tudmotu gave it a go (my first try at working on a gnome extension, and not proficient with js). I think I got most of my PR ready, but I get stuck with gsettings schema issues of some sort trying to add the option.
This error happens when I try open the settings (prefs.js
)
Error: Expected type utf8 for Argument 'key' but got type 'undefined'
This is the line I added (including other needed bits) that triggers the error
SettingsSchema.bind(Fields.CACHE_FILE_DISABLE, this.field_cache_disable, 'active', Gio.SettingsBindFlags.DEFAULT);
I'm not 100% sure how to apply defaults, should 'active'
be set as 'inactive'
. I gave up googling for docs related to SettingsSchema.bind - closest I could find was g_settings_bind
Hacking around, I even went into gnome-shell-extension-clipboard-indicator/schemas
, updated the .xml
with
<key name="cache-disable" type="b">
<default>false</default>
<summary>Disable the registry cache file and use memory only</summary>
<description>
If true, content is not stored and retrieved from a cache (registry.txt) file. If the extension is reloaded, then your copy paste history is lost. However, if you copy and paste passwords, then this helps avoid writing them to a plaintext file.
</description>
</key>
And ran
glib-compile-schemas .
So at this point, I'm getting quite fed up with how hard gnome / dconf make it to add one simple menu item. It's required 5 entries in prefs.js
to setup the toggle, the xml schema for dconf, not knowing how or when extensions bother to try use/install the schema for the extension. I did try bundle and install as a zip, no luck.
Any hints please?
https://github.com/JPvRiel/gnome-shell-extension-clipboard-indicator
from gnome-shell-extension-clipboard-indicator.
@Tudmotu thanks for helping spot that silly typo - obviously it was invisible to me! Will get to the PR and some santiy testing this weekend.
from gnome-shell-extension-clipboard-indicator.
PR #78 submitted. Tested it a bit. An extra tweak might be to delete registry.txt when toggled, but functional for now.
from gnome-shell-extension-clipboard-indicator.
@freeroot @Tudmotu this can now be closed? #78 has been merged. Of course, the option isn't on by default (don't want to disrupt other users who have come expect persistent history). You have to go to preferences and disable the file caching.
from gnome-shell-extension-clipboard-indicator.
Thanks a lot.
from gnome-shell-extension-clipboard-indicator.
Hi there, just a heads up / experience with this clear at boot feature - over and above reboot/shutdown, it also applies (looses history) when:
- logging out of gnome sessions,
- if gnome crashes and restarts, and
- if you suspend and resume.
Not ideal, but I still prefer the security at the cost of reliable/easy clipboard history.
from gnome-shell-extension-clipboard-indicator.
Another big annoying issue with using the extension memory I've found is locking and unlocking gnome seems to reload the extension and clear the history... This will need further investigation.
from gnome-shell-extension-clipboard-indicator.
All of those situations you are describing are situations where the extensions unload from memory. So for memory-only cache file, this is expected. Not much to do about it. Can think of some other impl, such as tmp-fs that was suggested before. Not sure when is it cleared exactly, but probably not between lock/unlock.
from gnome-shell-extension-clipboard-indicator.
I read somewhere that /tmp is empty at each boot. Maybe using a cache file in this folder can distinguish reboot and relock/relog.
from gnome-shell-extension-clipboard-indicator.
Can think of some other impl, such as tmp-fs that was suggested before. Not sure when is it cleared exactly, but probably not between lock/unlock.
Yeah, I considered that, but the "attack surface" is not as ideal. If we use tmpfs, then any process running as the user can read that file, regardless of it being in memory. Using the extension memory was better because there's extra effort/rights needed to get to the data...
I've opened a separate issue for this (given this one is technically closed): #91
from gnome-shell-extension-clipboard-indicator.
Related Issues (20)
- Features to hide icons in the top bar HOT 1
- Popup Placement when no indicator is there HOT 3
- Paste button pastes the contents of the clipboard in place of the selected item in the history
- [BUG] pop up notification no working. HOT 6
- Shortcuts HOT 8
- image support doesnΒ΄t work HOT 1
- Doesn't work due to clipboard entry parsing HOT 10
- Unhandled promise rejection. To suppress this warning ..
- Encoding problems HOT 4
- RCE vulnerability when copying full system paths HOT 16
- "Copied to clipboard" notification appears every time I copy anything, with no option to disable it HOT 1
- [BUG]: Unhandled promise rejection HOT 7
- "Text will be here" is displayed in the tray and nothing happens by clicking on it. HOT 22
- Lag - Delay HOT 5
- Suggestion: make it work as Win+V on windows HOT 2
- [BUG] In-menu keyboard controls do not work HOT 2
- Scroll Bar is Inaccessible To Mouse HOT 1
- shows sensitive information on next and previous entries HOT 2
- Non-Latin characters doesn't work HOT 2
- History clears on screenlock HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnome-shell-extension-clipboard-indicator.