Remember Numlock state after login in GNOME

gnome3keyboardnumlock

I am running Debian GNOME 8.0.
I would like to have Numlock ON as default.

So I followed the instructions on this page:

https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup#GDM
replacing gdm by gdm3 for my case.

This turns Numlock ON at login.
But then, after login, Numlock is automatically switched OFF again, and I cannot figure out how to leave it ON.

I looked at this page :

Keep NumLock always on

and edited my .bashrc file to add this line:

xmodmap -e "keycode # = """

which works to disable Numlock key. But since Numlock is OFF when my session opens, I could not turn it ON anymore! Thus it did not solve my problem. That would be useful if my Numlock was ON by default. (I re-enabled the Numlock key).

As information, I had initially installed Debian LXDE, but added GDM to switch to GNOME, and then removed and purged lxde* and lightdm*.
I feel like this is the reason for my problem, since:

  • I found on the web that LXDE switches numlock OFF as default

  • my other computer, on which I installed Debian GNOME natively, does not have this problem.

I am sure to be using GNOME since:

pierre@Ockham:~$ echo $XDG_SESSION_DESKTOP 
gnome
pierre@Ockham:~$ echo $GDMSESSION 
gnome
pierre@Ockham:~$ echo $XDG_CURRENT_DESKTOP 
GNOME

However, just in case lightdm would still play a role, I did try to follow the instructions on that page:

http://wiki.archlinux.org/index.php/LightDM#NumLock_on_by_default

and that one:

http://linuxquestions.org/questions/debian-26/howto-debian-7-wheezy-lxde-auto-numlock-both-before-and-after-login-4175500323/

but it did not solve the problem.

Does anybody have an idea?

By the way, the /etc/xdg/ folder still contains LXDE and Openbox (which I also removed) folders:

pierre@Ockham:/etc/xdg$ ls
autostart  libfm  lxlauncher  lxpanel  lxsession  menus  openbox  pcmanfm  systemd  user-dirs.conf  user-dirs.defaults

Is it normal or should I remove them? And how?

Best Answer

The solution was actually very simple (see @don_crissti 's comment): set the dconf key remember-numlock-state (under org > gnome > settings-daemon > peripherals > keyboard) value to true via dconf-editor or in terminal:

gsettings set org.gnome.settings-daemon.peripherals.keyboard remember-numlock-state true
Related Question