Suddenly setting caps:escape in xkb settings does not work anymore

I have been remapping caps lock to escape since starting nixos, and it has always worked.

Now I updated nixpkgs and suddenly caps lock is caps lock. I found nothing in here nor in the nixpkgs issues.

Current nixpkgs rev: b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef
Updated nixpkgs rev: adaa24fbf46737f3f1b5497bf64bae750f82942e

This is the configuration I have been using:

services.xserver.xkb = {
  layout = "us";
  model = "pc104";
  options = "caps:escape";
  variant = "altgr-intl";
};

I have always been on GNOME.

I am also experiencing this issue.

EDIT: I seem to have this issue only in vscode, adding

    "keyboard.dispatch": "keyCode"

To the vscode settings seems to have resolved the issue.

I think your issue is unrelated.

I’d recommend using keyd for that

here’s how I remap caps to ctrl:

  services.keyd = {
    enable = true;
    keyboards = {
      default = {
        ids = [ "*" ];
        settings = {
          main = {
            capslock = "layer(control)";
            rightcontrol = "rightcontrol";
          };
          otherlayer = { };
        };
      };
    };
  };

Looks nice, too.

I switched to udevmon temporarily:

{ pkgs, lib, ... }: {
  services.interception-tools =
    let
      inherit (pkgs.interception-tools-plugins) caps2esc;
      inherit (pkgs) interception-tools;
    in
    {
      enable = true;
      plugins = [ caps2esc ];
      udevmonConfig = lib.strings.toJSON [{
        JOB = builtins.concatStringsSep " | " [
          "${interception-tools}/bin/intercept -g $DEVNODE"
          "${lib.getExe caps2esc} -m 1 -t 0" 
          "${interception-tools}/bin/uinput -d $DEVNODE"
        ];
        DEVICE.EVENTS.EV_KEY = [ "KEY_CAPSLOCK" "KEY_ESC" ];
      }];
    };
}

I’m also seeing this issue in the past couple months. My config

services.xserver.xkb.options = "compose:ralt,ctrl:nocaps";

is no longer being propagated in a way that’s used by Gnome. I’m not sure if this is on Nix’s side or Gnome’s side.

If I manually touch the dconf value that Gnome uses here

$ dconf write /org/gnome/desktop/input-sources/xkb-options "['compose:ralt', 'ctrl:nocaps']"

then my Compose key starts functioning again and Caps lock gets disabled as expected.

This used to work fine (though I can’t remember if this dconf value was ever getting set using this configuration system).

I also notice that

$ setxkbmap -print -query
WARNING: Running setxkbmap against an Xwayland server
xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwerty)" };
        xkb_types     { include "complete"      };
        xkb_compat    { include "complete"      };
        xkb_symbols   { include "pc+us+inet(evdev)"     };
        xkb_geometry  { include "pc(pc105)"     };
};
rules:      evdev
model:      pc105
layout:     us

has no information about this configuration

The conf file does appear to be getting written though

$ cat /etc/X11/xorg.conf.d/00-keyboard.conf
Section "InputClass"
  Identifier "Keyboard catchall"
  MatchIsKeyboard "on"
  Option "XkbModel" "pc104"
  Option "XkbLayout" "us"
  Option "XkbOptions" "compose:ralt,ctrl:nocaps"
  Option "XkbVariant" ""
EndSection

After much nixpkgs bisecting, I’ve determined that this started occurring when the GNOME: 47 → 48 PR was merged.

I haven’t yet been able to bisect which exact commit/package though because the PR was merged without squashing and most (all?) of the intermediate commits fail to build my system due to compilation errors with glib/gtk etc.

I’m very suspicious of this commit to gnome-settings-daemon, though: keyboard: Do not load xkb-options from localed when explicitly set to empty (3a9fce09) · Commits · GNOME / gnome-settings-daemon · GitLab . I notice that my dconf setting for /org/gnome/desktop/input-sources/xkb-options is populating to an empty list:

$ dconf read /org/gnome/desktop/input-sources/xkb-options
@as []

and that commit will make it stop getting written to.

2 Likes

Any update? I just had a fresh install of 25.11 with Gnome and I am facing the same problem.

xkb.options seems to be ignored.

Based on @ignormies dconf idea, I am now setting the home-manager dconf.settings option to

  dconf.settings = {
    "org/gnome/desktop/input-sources" = {
      xkb-options = "caps:escape";
    };
  };

.