25

On my Debian system I've customized my Gnome (Shell) keyboard shortcuts, via System Settings > Keyboard > Shortcuts.

Where do I find the file with these settings so that I can copy the file onto a flash drive for backup and then use it to replace the keyboard shortcuts on other Gnome systems?

22

Gnome 3 uses DCONF to store the preferences in a single binary file: ~/.config/dconf/user.
As per the Gnome docs, it is recommended to save only the settings that you need and restore them with either dconf or gsettings. However, gsettings is only able to restore the value(s) for one single key at a time (plus, the value must be quoted) and that makes it a bit awkward for this kind of task. Which leaves us with dconf.
So, in this particular case, save the current settings for gnome-shell keyboard shortcuts1:

dconf dump /org/gnome/shell/keybindings/ > bkp

Here's a bkp sample:

[/]
toggle-message-tray=['<Super>m']
open-application-menu=['<Super>F1']
toggle-application-view=['<Control>F1']
focus-active-notification=['<Super>n']
toggle-recording=['<Control><Shift><Alt>r']

Load the settings on another system:

dconf load /org/gnome/shell/keybindings/ < bkp

1: WM and Media Keys shortcuts belong to different schemas:

/org/gnome/desktop/wm/keybindings/
/org/gnome/mutter/keybindings/
/org/gnome/mutter/wayland/keybindings/
/org/gnome/settings-daemon/plugins/media-keys/

Note that dconf only dumps non-default values so if you run e.g.

dconf dump /org/gnome/desktop/wm/keybindings/

and don't get any output that means there's no custom WM shortcut defined.


As a side note, dconf-editor is a tool that helps visualizing dconf settings structure, i.e. schema [:path] key value, the type and the default values of any key etc.


For the record, saving the preferences with gsettings:

gsettings list-recursively org.gnome.shell.keybindings > bkp

bkp sample:

org.gnome.shell.keybindings focus-active-notification ['<Super>n']
org.gnome.shell.keybindings open-application-menu ['<Super>F1']
org.gnome.shell.keybindings toggle-application-view ['<Super>a']
org.gnome.shell.keybindings toggle-message-tray ['<Super>m']
org.gnome.shell.keybindings toggle-recording ['<Control><Shift><Alt>r']

Now loading the preferences (as I said, for each line in the backup file you need a separate command and don't forget to quote the values):

gsettings set org.gnome.shell.keybindings focus-active-notification "['<Super>n']"
gsettings set org.gnome.shell.keybindings open-application-menu "['<Super>F1']"
gsettings set org.gnome.shell.keybindings toggle-application-view "['<Super>a']"
gsettings set org.gnome.shell.keybindings toggle-message-tray "['<Super>m']"
gsettings set org.gnome.shell.keybindings toggle-recording "['<Control><Shift><Alt>r']"
  • dconf dump /org/gnome/shell/keybindings/ > bkp does not work on Centos 7. – Lucas Feb 15 '17 at 20:36
  • Sorry, I was trying to edit my comment and got blocked by stack exchange. Doing a dconf dump / can help show what keys are available though. On Centos I had the terminal bound to Ctrl+Alt+T and it shows up in org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0. Dumping org/gnome seems like a good way to backup most things on Centos 7. – Lucas Feb 15 '17 at 20:52
  • For anyone using custom keyboard shortcuts for non-defaults actions: These are stored in /org/gnome/settings-daemon/plugins/media-keys/ under custom-keybindings (as an example: I've defined some shortcuts to place the mouse pointer at the center of each of my screens). – decibyte Jun 8 '18 at 8:16
  • No /org/gnome/shell/keybindings/ on Fedora 28. – anatoly techtonik Dec 25 '18 at 6:08
  • @don_crissti dconf only saves settings that are modified, and it saves them at different locations. – anatoly techtonik Dec 26 '18 at 3:29
0

Search for keybindings like so:

gsettings list-recursively | grep keybindings

Set a keybinding like so:

org.gnome.desktop.wm.keybindings close "['<Alt>F5']"

Note that keyboard tweaks overlapping bindings will break the latter. For instance, switch-applications-backward ['<Alt><Shift>Tab'] will be overridden by layout switch "Left Alt" + "Left Shift", so that ['<Left Alt><Left Shift>Tab'] will not work, where as ['<Left Alt><Right Shift>Tab'] will.

Setting keybinding for layout switch like so gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Shift>Alt', '<Super>space']" or gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['<Alt>Shift', '<Super>space']" does not make it work.

Hope someone will find this useful.

Gnome v3.28.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.