Good ways to export all keyboard hotkeys?
-
@Pathduck said in Good ways to export all keyboard hotkeys?:
Any more or better ways?
- Open Settings in a Tab (Settings, Appearance) and take a screenshot with FastStone Capture or similar on other platforms (Vivaldi's Capture Page does not work)
- Display the Cheat Sheet on a portrait monitor and take screenshots of each of the four pages. FastStone Capture can be used to capture the scrolling dialog. (This shows only commands that have shortcuts assigned. The former method also shows commands with no shortcut assigned)
Updated for Vivaldi 5.8 Snapshot (30/3/2023)
-
@Pathduck There’s a good amount of shortcuts in local storage, but the collection is simply incomplete. I wonder why this hasn’t been added to Vivaldi Sync yet. One possible explanation is that people will use different shortcuts on different platforms (e.g. ‘command’ on macOS versus ‘control’ on Windows), but that could be handled by Sync separately.
-
@luetage Yeah, I tried looking through the Preferences and Secure Preferences files, they are not there. So they are probably in the local storage under
Local App Settings\mpognobbkildjkofajifpdfhcoklimli
. But that file is impenetrable unless you're a coder.I tried to use
chrome.storage.local.get()
in the console like you do in the search engines mod, but couldn't figure out how to find what values to query or how to convert the objects it into something readable... any pointers on where to look? For instance, how do you know to look for "SEARCH_ENGINE_COLLECTION"?What I've done now is simply open settings, open the Cheat Sheet, press F12 for Devtools, then search for
keyboard-shortcut-list
, copy the wholekeystrokes
element, then run it through HTML Tidy to make a proper html page... not exactly elegant, but at least it's something usableWhat @Pesala does is good too I guess, but I prefer to have it in a format like this and not a big picture. Hope they can make an export feature or at least add hotkeys to the Sync data soon.
-
Try this:
chrome.storage.local.get(function(this){console.log(this)})
-
This should export only keyboard shortcuts:
chrome.storage.local.get(st => { let exp = {}; Object.keys(st).forEach(k => { if (k.startsWith('COMMAND_') && st[k]['shortcut']) exp[k] = st[k]['shortcut']; }); console.log(JSON.stringify(exp)); });
and this also gestures etc. (it’s a little easier to import back)
chrome.storage.local.get(st => { let exp = {}; Object.keys(st).forEach(k => { if (k.startsWith('COMMAND_')) exp[k] = st[k]; }); console.log(JSON.stringify(exp)); });
But note that only non-default shortcuts (or those you manually changed to default) are stored, so if any default changes (like
Alt-P
→Ctrl-F12
), you’ll have to customise it even after importing. -
@potmeklecbohdan @luetage
Thanks a lot guys!Using the first example I was able to get to:
chrome.storage.local.get(function(back){console.log(JSON.stringify(back));});
This would of course export everything as JSON which I guess is better if you wanted to import it back in. It would be nice to have it in a more readable format as well, but I will try running it through json_pp to pretty it up.
I was unable to also do a copy to clipboard using sample code from the mod, but not such a big deal.
chrome.storage.local.get(function(back){navigator.clipboard.writeText(JSON.stringify(back));});
Gives an error of "Uncaught (in promise) DOMException: Document is not focused."Importing back would be more complicated if there's only part of it I guess? Then again, hopefully I won't need to and certainly won't risk testing it at the moment. I really need just a list to be able to easy recreate in case of a total FUBAR.
BTW using "this" gave me an error because it's a keyword (apparently):
Uncaught SyntaxError: Unexpected token 'this' -
@Pathduck Don’t think it makes sense at the moment, it either has to be added to sync, or the complete shortcuts need to be accessible in storage, preferably encompassing.
-
@luetage Yeah, I did a quick test comparing the exported html from the cheat sheet and the prettified JSON:
$ grep -e "<input.*/>" Vivaldi-keyboard.html | wc -l 155 $ grep "\"shortcut\"" Vivaldi-settings-pp.json | wc -l 132
So something is missing, but what, and where is it???
EDIT: Forgot that the html contains an input element for each individual hotkey so would be doubled if two keys are assigned to the same command. That should bring them to about the same value, maybe (harder to test)...
-
- I think you should
grep
fordata-raw
, because theinput
s are for inputting new keys (the colorful thingy arebutton
s). However, this would mean that you have to use different way to count the JSON hotkeys…
chrome.storage.local.get(st => { let exp = []; Object.keys(st).forEach(k => { if (k.startsWith('COMMAND_') && st[k]['shortcut']) exp.push(...st[k]['shortcut']); }); console.log(exp.length); });
- Don’t forget that there is some chance you let some defaults be (and have never touched them), so these aren’t in the storage.
- I think you should
-
@potmeklecbohdan Good catch, I edited my post above, doing this I got the same result:
$ grep "\"name\" : \"COMMAND_" Vivaldi-settings-pp.json | wc -l 144
And for the html there are two or even three elements sometimes for one command.
-
So is there any reasonable way to sync my shortcuts, or I have to write them down and enter manually each time I install browser? (Or you just gracefully close thread for necroposting?)
-
@Pesala said in Good ways to export all keyboard hotkeys?:
- Open Settings in a Tab (Settings, Appearance) and take a screenshot with FastStone Capture or similar on other platforms (Vivaldi's Capture Page does not work)
- Display the Cheat Sheet on a portrait monitor and take screenshots of each of the four pages. FastStone Capture can be used to capture the scrolling dialog. (This shows only commands that have shortcuts assigned. The former method also shows commands with no shortcut assigned)
-
@fires3as0n said in Good ways to export all keyboard hotkeys?:
enter manually each time I install browser
With respect, i don't really understand that "logic". Whilst i emphatically agree that V really really really needs to give users better tools for easily managing important data like this, even atm sans-that, IMO there is still an effective albeit ugly unsophisticated way, rather old-school. My entire V
~/.config/vivaldi-snapshot
directory is included in my mid-week & end-week backups. In the event of any SSD catastrophe wiping out my source data, i have my backups for recovery. In the event of doing a new V installation on another pc or in a new VM, i simply replace that vanilla config data with mine, & voilà. Inelegant, sure, but entirely effective. -
@guigirl It’s only effective as long as your profile is healthy. As soon as that deteriorates you run into all the unsynced stuff and cry a little. We need command chains, menu customization and keyboard shortcuts backups/sync badly.
-
@luetage Afaik, in the entire history of time, space & dolphins, no Vivaldifarian has ever ever ever suffered from an unhealthy profile
Anyway, given this thread nominally canvasses...
Good ways to export all keyboard hotkeys?
. rather than...
Good ways to sync all keyboard hotkeys?
, you are hereby formally [i'm wearing a ballgown] flagged for gratuitous OT.
-
@guigirl That’s some advanced argumentation. I admit defeat and apologize for my off‐topic ways.
-
@luetage There you go again! OT OT OT. Honestly, it's so hard these days to get the right class of forummer! There should be laws...
-
@Pesala na, this sucks.
-
WTF, this feature has been missing since day 1. Enough already, sync the shortcuts with all the other settings. Shame on Vivaldi for avoiding this.
-
@nullsteph Sync more Features is one of the most upvoted requests.
Personally, I think Export/Import for Users Settings would be more useful.
Everyone has their own pet bugs and feature requests. Let the developers decide what they think is the top priority to avoid unnecessary stress. Pray for the courage to change what should be changed, the patience to accept what cannot be changed, and above all, for the wisdom to know the difference.