Activating numlock on bootup

From ArchWiki
Revision as of 23:25, 11 June 2019 by Brnelsons (talk | contribs) (Updated the XFCE documentation to include creating the keyboards.xml file when it does not exist.)
Jump to navigation Jump to search


Using a separate service

Tip: These steps can be automated by installing the systemd-numlockonttyAUR package and enabling the numLockOnTty service.

First create a script to set the numlock on relevant TTYs:


for tty in /dev/tty{1..6}
    /usr/bin/setleds -D +num < "$tty";

Then create and enable a systemd service:




Extending getty@.service

This is simpler than using a separate service and does not hardcode the number of VTs in a script. Create a drop-in snippet for getty@.service which are applied on top of the original unit:

ExecStartPre=/bin/sh -c 'setleds -D +num < /dev/%I'
Note: If you experience any problems, try replacing ExecStartPre with ExecStartPost, and/or disabling the hint as described below.

To disable the num-lock activation hint displaying on the login screen, edit getty@tty1.service and add --nohints to agetty options:

ExecStart=-/sbin/agetty '-p -- \\u' --nohints --noclear %I $TERM

Bash alternative

Add setleds -D +num to ~/.bash_profile. Note that, unlike the other methods, this will not take effect until after you log in.

Various methods are available.


Install the numlockx package and add it to the ~/.xinitrc file before exec:

# ~/.xinitrc
# Executed by startx (run your window manager from here)

numlockx &

exec window_manager


By default, MATE saves the last state on logout and restores it during the next login. To enable Numlock on every login, you must change the following DCONF-Values:

dconf write org.mate.peripherals-keyboard remember-numlock-state false
dconf write org.mate.peripherals-keyboard numlock-state 'on'

KDE Plasma Users

Go to System Settings, under the Hardware/Input Devices/Keyboard item you will find an option to select the behavior of NumLock.


Note: GDM does not execute scripts in /etc/gdm/Init anymore.

Make sure that you have numlockx installed then add the following code to ~/.xprofile:

if [ -x /usr/bin/numlockx ]; then
      /usr/bin/numlockx on


When not using the GDM login manager, numlockx can be added to GNOME's start-up applications.

Install the numlockx package. Then, add a start-up command to launch numlockx.

$ gnome-session-properties

The above command opens the Startup Applications Preferences applet. Click Add and enter the following:

Name: Numlockx
Command: /usr/bin/numlockx on
Comment: Turns on numlock.
Note: This is not a system-wide change, repeat these steps for each user wishing to activate NumLock after logging in.


In the file ~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboards.xml, make sure the following values are set to true:

<property name="Numlock" type="bool" value="true"/>
<property name="RestoreNumlock" type="bool" value="true"/>

Note: If the file does not exist then open Settings > Keyboard, then check and uncheck the Template:Restore num lock state on startup. This will create the Template:Keyboards.xml file.


In the file /etc/sddm.conf, under the [General] section, set Numlock value to on :



In the file /etc/slim.conf find the line and uncomment it (remove the #):

#numlock             on


In the file ~/.config/openbox/autostart add the line:

numlockx &

And then save the file.


See LightDM#NumLock on by default.


Set the option in /etc/lxdm/lxdm.conf:



Set the option in ~/.config/lxqt/session.conf: