Nixos options to configure Gnome Keyboard Shortcuts

Just to follow up on this, I did get it working eventually. I had a couple false starts, so I think it’s useful to post this for anyone else trying to do this, and to see if someone suggests something I could do better.

First, to go over my solution:

I adding the following to my Home-manager config:

dconf.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 = "<Primary><Alt>t";
  command = "alacritty";
  name = "open-terminal";
};

I should note, that the leading and trailing / in custom-keybindings was critical. Originally I didn’t have them, and without that I got into a state where gnome would crash as soon as I logged in. This wasn’t something that went away by booting a previous generation, and the only way I recovered was logging in as root, and restoring ~/.config/dconf/user from a previous filesystem snapshot, git stashing my config changes and doing a nixos-rebuild

Per this, I also had to add the below to get Home-manager to actually apply my dconf changes.

services.dbus.packages = [ pkgs.gnome3.dconf ]; 

Other than all that, it was easy… :smile:

2 Likes