24

Is it possible to backup the custom keyboard shortcuts and restore them when doing a fresh install?

user10853
  • 1,626
orschiro
  • 13,687

2 Answers2

26

Gnome-Control-Center (used by Unity and Gnome Shell) stores its key bindings in the per-user Dconf database directories /org/gnome/desktop/wm/keybindings/ and /org/gnome/settings-daemon/plugins/media-keys/ (source).

  • The easiest way to keep them across system re-installations is to keep the per-user configuration directories (~/.config or more specifically ~/.config/dconf/user for Dconf only). Most of the time it's not necessary or desirable to purge the per-user configuration files anyway.

  • If you can't or won't keep your old Dconf database you can use the dconf command to export (“dump”) parts of it into a file and import (“load”) it later. The relevant Dconf directories are

    • /org/gnome/desktop/wm/keybindings/ for pre-defined shortcuts and
    • /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/ for custom, user-defined shortcuts.

    The following example saves the above Dconf directories to two files keybindings.dconf and custom-keybindings.dconf and then restores them from the same files:

    dconf dump '/org/gnome/desktop/wm/keybindings/' > keybindings.dconf
    dconf dump '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/' > custom-keybindings.dconf
    
    dconf load '/org/gnome/desktop/wm/keybindings/' < keybindings.dconf
    dconf load '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/' < custom-keybindings.dconf
    

If you find that you export your keybindings often, it might be convenient to script the required steps.

peterrus
  • 398
David Foerster
  • 36,890
  • 56
  • 97
  • 151
0

Case you are a fan of Xubuntu (xfce), here is the clue:

/home/$USER/.config/xfce4/xfconf

Credits: https://www.reddit.com/r/xfce/comments/f60aan/whats_the_right_way_to_export_my_xfce_keyboard/?rdt=33301