I usually load a new version for every release to keep my OS fresh while preserving the last version on another partition as backup. I also employ a lot of custom key mappings.
I've figured out how to transfer the majority of my configuration across systems so far but I can't figure out where the custom keyboard shortcut mappings are stored.
Does anybody know where gnome puts these? Are there separate user config (i.e., ~/) and system config (i.e. /etc) files?
Best Answer
Ubuntu has changed since other answers to this question were written.
Keybindings have moved from gconf to dconf. Gconf stores its data in xml files and was accessed by
gconf-editor
andgconf-tool2
. Dconf stores its data in a binary format and is accessed bydconf-editor
andgsettings
.The number of places that keybindings are stored is reduced. There is now a centralized dconf path to store window manager keybindings (
org.gnome.desktop.wm.keybindings
). There are mapping files in the directory/usr/share/gnome-control-center/keybindings/
that show how these are applied based on the window manager you are actually using (compiz or metacity).A second set of non-window-manager related key bindings is stored in the dconf path
org.gnome.settings-daemon.plugins.media-keys
There is a third set of keybindings related to power buttons that is stored in the dconf path
org.gnome.settings-daemon.plugins.power
. There is currently a bug in the GUI that lets you configure keybindings. It doesn't know about these settings. I have a "sleep" button on my keyboard. If I want to reassign it to other functionality, I have to disable the setting inorg.gnome.settings-daemon.plugins.power
manually. The GUI doesn't do it for me (although it assigns the new functionality just fine).The other wrinkle is custom key bindings. These are stored in dconf using relocatable schema. Its done this way because there are an arbitrary number of them. A reasonable approach, but it makes listing or modifying them via the command line harder than it should be.
I also found out that the GUI that allows you to assign keybindings is limited in a way that annoys me. The GUI allows exactly ONE keybinding to be assigned to each action. In dconf, you can set an array of bindings for a single action. This is useful to me. For example, I like to have the "close-window" action assigned to the traditonal Alt-F4 as well as to an easier to hit single button on my keybord.
I have written a Perl script to dump all the keybindings to a csv file, or restore them from the csv file. For example to dump the keybindings you might use:
./keybindings.pl -e /tmp/keys.csv
and to restore them you might use:
./keybindings.pl -i /tmp/keys.csv
This includes the fix by user2589537 to allow custom commands with quotes in them.