Closed Filbuntu closed 1 year ago
Not really, it's based on usage. You could click your favorites in the reverse order you want them to be sorted, but they'll get messed up once you use them normally again.
Thank you for the fast reply! Sayang that there is no way to sort it. Could this be a feature to implement in the future? Where are the favourites saved?
Could this be a feature to implement in the future?
Probably not: trying to build UI in gnome extensions is a massive pain.
where the clipboard favorites and history are saved
This extension uses a binary format so you're not going to be able to edit it easily. It's in ~/.cache/clipboard-history@alexsaveau.dev/database.log
. That said, there is serialization/deserialization tooling which you might be able to adapt to your use case: https://github.com/SUPERCILEX/gnome-clipboard-history/blob/master/tools/src/main.rs.
Thank you for your interesting answer!
Probably not: trying to build UI in gnome extensions is a massive pain.
This is a pity! Hopefully this will get better as GNOME extensions are handy and hopefully have a bright future.
This extension uses a binary format so you're not going to be able to edit it easily. It's in
~/.cache/clipboard-history@alexsaveau.dev/database.log
. That said, there is serialization/deserialization tooling which you might be able to adapt to your use case: https://github.com/SUPERCILEX/gnome-clipboard-history/blob/master/tools/src/main.rs.
I could indeed find the log and read my copied text and favourites. There is a pattern for the favourites (##text####) but you are right that I can not edit it easily, e.g, with a text editor or LibreOffice. Unfortunately, I don't know how to use the serialization/deserialization tooling main.rs. Can you give me some hints?
I don't know how to use the serialization/deserialization tooling main.rs
You won't be able to just use it, you'll need to write your own code that fits your use case. If that's too difficult I recommend using the paste/click to reorder method.
Unfortunately I don't have coding skills :see_no_evil:. "paste/click": You mean "click your favorites in the reverse order you want them to be sorted"? First tests are promising that the app Ghex (GNOME Hex Editor) can edit the binary format file database.log.
BUT I realised that with paste/click the order would change immediately, e.g. if I select one of the favourites it would jump to the first place. You wrote about this but I did not realise this as I only started to use this extension and with the former extension "clipboard-indicator" the favourites list order is kept, also if you click/select one to paste and only new favourites will be added to the top. I wonder whether the feature of fixed favourites list order can be brought back (e.g. as an option in the settings or generally) as the workflow would be more efficient. When I know the order I can find the specific favourite more quickly and my brain can automatically click on it. And with the constantly changing order editing with Ghex does not make sense.
Hmmm, if you don't want the order to ever change, you could probably just add an && !entry.favorite
: https://github.com/SUPERCILEX/gnome-clipboard-history/blob/348685b129f7914edf0bfb48f13df6352506ba5c/extension.js#L874 That shouldn't break anything I think?
The extension code lives in ~/.local/share/gnome-shell/extensions
.
If this works, this would be great! I could sort the list with click/paste and then fix it with the added code.
But I could not figure out where I should exactly place && !entry.favorite
in the 874th line. I tried all the possible positions but it would not fix the list*. But it also did not break anything 😄. Any tip? E.g. if (!isFirst && !entry.favorite) {
?
Thank you again for your help!
*I disabled the extensions with the Extensions Manager, edited extension.js file in ~/.local/share/gnome-shell/extensions/clipboard-history@alexsaveau.dev
and enabled the extension again.
Oh, nothing will change unless you restart gnome: https://github.com/SUPERCILEX/gnome-clipboard-history#restart-gnome
Thanks for the tip (I will use Alt + F2 then type r)!
Where exactly should I place && !entry.favorite
in the 874th line?
if (!isFirst && !entry.favorite)
is right
Mmh, it did not yet work. I will look into it tomorrow again. Thanks again for your help!
Even after restart it still does not work. I have following for line 874-6:
if (!isFirst && !entry.favorite) {
this._moveEntryFirst(entry);
}
When I click on one of the favorites it still moves to the first place of the favorites list (which means the favorites list order is changed). Any other tip? It would be such a great help to have a fixed/unchanging favorites list with just a bit of code (which I delete when I want to change the list order).
Oh wait, I'm being dumb, sorry. That one is for when you re-copy an item. You'll want to slap an if statement around this one (which gets called when you paste): https://github.com/SUPERCILEX/gnome-clipboard-history/blob/348685b129f7914edf0bfb48f13df6352506ba5c/extension.js#L644
No worries! Even the best can have a flaw in reasoning.
I am still not a coder 😊. What do you mean with "slap an if statement around this one"?
I tried with following, but it did not work:
if (this._moveEntryFirst(menuItem.entry));
if (!menuItem.entry.favorite) this._moveEntryFirst(menuItem.entry);
It says, if this entry is not a favorite, move it to the top.
Thanks a lot! This did the trick. Here a summary if someone else wants to profit from this hack to fix the order of the favourites. Change Line 644 in extension.js file in ~/.local/share/gnome-shell/extensions/clipboard-history@alexsaveau.dev:
https://github.com/SUPERCILEX/gnome-clipboard-history/blob/348685b129f7914edf0bfb48f13df6352506ba5c/extension.js#L644
to
if (!menuItem.entry.favorite) this._moveEntryFirst(menuItem.entry);
and restart GNOME Desktop with Alt + F2, then type r.
Is there a way to sort the favourites? I could not find the place where the clipboard favorites and history are saved. Potentially it can be sorted there. Any tip?