Enable numlock on GDM?

How can I enable numlock on GDM, I’ve tried switching to SDDM and there it is working, but I’d want to enable it on GDM on boot and when I login/logout from session.

Also I’ve tried numerous numlockx services and none of them worked for me.

My dotfiles: GitHub - cafetestrest/nixos

Thank you.

Hi, I don’t thing this is possible in NixOS.
Perhaps try switching to sddm or lightdm.

GDM uses Wayland by default so random services that expect X server will not work. Furthermore, to support both X server and Wayland GNOME is not supposed to be controlled through X-specific settings but rather through gnome-setting-daemon, which abstracts many of the low-level details.

If you have home-manager enabled in your NixOS configuration, you should be able to just set the following for gdm user:

dconf.settings = {
  "org/gnome/settings-daemon/peripherals/keyboard" = {
    numlock-state = "on";

Edit: the settings were moved, see the comment below.

It is possible to achieve it without home-manager but it requires a bit more code, see the last paragraph in Need help for NixOS Gnome scaling settings - #5 by jtojnar.

1 Like

Thank you for detailed explanation, I’m amazed of how powerful NixOS can be.
To make it work, I’ve added a new user - gdm to home-manager, and the following piece of code made it numlock stay on:

home-manager.users.gdm = { lib, ... }: {
  dconf.settings = {
    "org/gnome/desktop/peripherals/keyboard" = {
      numlock-state = true;
      remember-numlock-state = true;
  home.stateVersion = "23.05";

Really grateful for the help and teaching me new stuff. I’m newbie when it comes to NixOS.

Good catch, I forgot that the option was moved from g-s-d to g-d-s, was copying it from my dconf database.

Also note that remember-numlock-state is already true by default:

The reason the numlock-state is not persisted is that we put GDM’s home-directory into a in-memory temporary directory, which gets cleaned when computer shuts down.

1 Like