Wed Mar 14, 2018 7:18 am
Where is/are the configuration file(s) that store(s) keyboard shortcuts of KDE products such as KDE Plasma 5, Konsole and KWrite?
I would like to back up my custom settings for keyboard shortcuts so that I can restore them in the future when further customizations of shortcuts mess things up.
Standard Shortcuts and Global Shortcuts can be customized on GUI by `System Settings > Workspace > Shortcuts`. Shortcuts specific to Konsole can be customized by `Konsole > Settings > Configure Shortcuts...`. Shortcuts specific to KWrite can be customized by `KWrite > Settings > Configure Shortcuts...`.
I do not see any export, save or load button on the GUI dialog window. (I am on Debian 9.3.) So, I am thinking about backing up the configuration file(s) directly. Where is/are the configuration file(s) that store keyboard shortcuts?
I looked into `~/.kde/share/config` and `/etc`, but could not find anything that seems to store keyboard shortcuts.
Recent KDE products may store the settings somewhere different from where old KDE used to store. I would like to know about KDE products that come with Debian 9. Debian 9.3 comes with Plasmashell 5.9.4, Konsole 16.12.0 and KWrite 16.08.3.
Wed Mar 14, 2018 8:39 am
I found shortcuts in the same folder that stores my customized toolbars.
Sat Apr 28, 2018 9:44 pm
I am going to write the following three things:
- How to find these preference files
- How to back up and restore them
The following files store the keyboard shortcuts of KDE Plasma 5 and of some of its associated applications such as Konsole and KWrite.
Let me add descriptions for the files.
Standard Shortcuts (System Settings > Shortcuts)
Global Shortcuts (System Settings > Shortcuts)
"Custom Shortcuts" (System Settings > Shortcuts)
KWrite > Settings > Configure Shortcuts... > KWrite
KWrite > Settings > Configure Shortcuts... > Kate Part
Among "Global Shortcuts", "Plasma > Activate Application Launcher Widget" is also stored in
in addition to the common
This is because "Activate Application Launcher Widget" can be also set by
Right-click "Application Launcher" > Application Launcher Settings... > Keyboard Shortcuts
The dissociation of Meta key (a.k.a. Windows Key or Apple Command Key) from the Kickoff Application Launcher (a.k.a. Start Menu) is stored in
I dissociated the Meta key from the Application Launcher by the command:
This command adds the following two lines into "~/.config/kwinrc".
Except "kglobalshortcutsrc" and "khotkeysrc", these files store only custom shortcuts but not default shortcuts, but also store other kinds of preferences. "kglobalshortcutsrc" stores both custom and default shortcuts, but does not store other kinds of preferences. "khotkeysrc" seems similar to "kglobalshortcutsrc".
How to Find the Preference Files of Keyboard Shortcuts
First, add some custom shortcuts whose modifier key is Meta or Control, say "Meta+C" or "Ctrl+Tab", to "System Settings > Shortcuts > Standard Shortcuts" and "System Settings > Shortcuts > Global Shortcuts" and to "Configure Shortcuts" of individual applications.
Then, by the following command, conduct a content search to look for files that contain the keyword 'Meta+', 'Ctrl+' or 'Meta=', searching in the home directory ~.
The resultant files are good candidates for the files storing keyboard shortcuts. Examine each file to see whether it actually stores keyboard shortcuts.
I thank TKL-Ansi for "~/.local/share/kxmlgui5", which is the directory enclosing the files that store the custom keyboard shortcuts of individual applications. I found the other files on my own.
Back Up and Restore the Keyboard Shortcuts
Generally, the "System Settings" does not provide GUI methods to export or import settings. Under "System Settings > Shortcuts", only when "Global Shortcuts" is selected, the File popup menu emerges near the lower right corner of this System Settings window, and provides the "Import Scheme..." and "Export Scheme..." menu items. This File popup menu disappears when "Standard Shortcuts" or "Custom Shortcuts" is selected.
I need to back up not only Global Shortcuts but also other shortcuts. The following command backs up the nine preference files containing keyboard shortcuts into the archive file "KeyboardShortcut.tar.gz".
Note that, as stated above, these preference files (except "kglobalshortcutsrc" and "khotkeysrc") contain not only keyboard shortcuts but also other kinds of preferences. Therefore, when these preference files are restored, not only keyboard shortcuts but also other kinds of preferences will be restored, overwriting the existing ones, which may or may not what you want. (I am thinking about writing commands to back up and restore only keyboard shortcuts without interfering with other kinds of preferences; but not now.)
To restore these preference files, do the following command with the current directory being your home directory, preferably in the rescue mode (recovery mode).
The reason that this restoration should be done in the rescue mode follows. For each preference file, Plasma and other applications likely keep an extra copy in the memory besides the one on the disk. When they quit, they may possibly update the preference files by overwriting those on the disk with those in the memory. Therefore, if the preference files are restored from KeyboardShortcut.tar.gz to the disk while Plasma and other applications are running, the restored copies may be overwritten and destroyed when they quit.
Therefore, it is better to restore them while Plasma and other applications are not running. To do so, restore them in the recovery mode (rescue mode). Thus, enter the recovery mode from the GRUB menu when the computer starts up, and log in as "root". Note that, normally, the tilde (~) indicates your home directory; however, while logged in as root, ~ means "/root". Hence, you need to cd to your own home directory first. Then, execute
To get out of the rescue mode, execute
These commands here are expected to run on bash.
KDE Plasma 5