Changing numeric keyboard to produce dot instead of comma

Here’s the piece of my current configuration that defines locales:

{ config, pkgs, ... }:

{
  time.timeZone = "Europe/Zurich";
  
  i18n = {
    defaultLocale = "en_GB.UTF-8";
    extraLocaleSettings = { };
  };

  services.xserver = {
    layout = "pl";
    xkbVariant = "";
  };

  console.keyMap = "pl2";
}

It almost works as I’d like to. “Almost”, as the numeric decimal spearator key (i.e. the one with label “. DEL” on it) produces a comma, instead of a more useful dot, as in Polish convention a comma is a decimal separator.

Is it possible to keep the PL layout, but override the numeric keyboard decimal separator to produce a dot?

I guess this is something I need to play with.

Answering my own question :).

1.) I found out that setting xkbOptions to "kpdl:dot" should do the trick. However, it doesn’t work for me. I guess this is because I use Wayland.
2.) I solved the problem by installing and configuring keyd. In my case the configuration was trivial:

services.keyd = {
  enable = true;
  keyboards.default = {
    ids = [ "*" ];
	settings = {
	  main = {
	    kpdot = ".";
	  };
    };
  };
};

“kpdot” is the name of the “numeric del” key.
In case you needed to modify other keys but didn’t know its code, you can run sudo keyd --monitor. Then press the key and you’ll see the code.

Also, my experience shows that adding keyd to configuration.nix in this way doesn’t add keyd binary to your PATH. I solved it by running nix-shell -p keyd before executing the command with --monitor switch.

1 Like