Nixos options to configure Gnome Keyboard Shortcuts

gnome-settings-daemon is configured through GSettings, ordinarily stored in dconf database.

Usually, the best way to set it declaratively is to set it in the GUI and then look in dconf-editor or the output of dconf dump to see what changed. In my case it were these settings:

[org/gnome/settings-daemon/plugins/media-keys]
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']

[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0]
binding='<Super>t'
command='gnome-terminal'
name='Open terminal'

You can then set the default values in configuration.nix:

{
  services.xserver.desktopManager.gnome3 = {
    extraGSettingsOverridePackages = with pkgs; [ gnome3.gnome-settings-daemon ];
    extraGSettingsOverrides = ''
      [org.gnome.settings-daemon.plugins.media-keys]
      custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']


      [org.gnome.settings-daemon.plugins.media-keys.custom-keybindings.custom0]
      binding='<Super>t'
      command='gnome-terminal'
      name='Open terminal'
    '';
  };
}

Note you will have to reset them using dconf reset for the defaults to be picked up.

But that might not work since /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ is a relocatable schema.

home-manager has a dconf.settings option that should work, though.

3 Likes