Activating Numlock on Bootup

From ArchWiki
Jump to: navigation, search


Using a separate service

  • Alternatively, if you do not want to install an aur package to implement this, you can simply create a service file in /etc/systemd/system like:
    Description=Switch on numlock from tty1 to tty6
    ExecStart=/bin/bash -c 'for tty in /dev/tty{1..6};do /usr/bin/setleds -D +num < \"$tty\";done'
    Note: The filename should have a .service suffix, e.g. numlock1to6.service.
    Do not forget to enable the service after you create it.

Extending getty@.service

This is simpler than using a separate service (especially since systemd-198) and does not hardcode the number of VTs in a script. Create a directory for drop-in configuration files:

# mkdir /etc/systemd/system/getty@.service.d

Now add the following file in this directory.

ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'

To disable the num-lock activation hint displaying on the login screen, edit /etc/systemd/system/ Add the option '--nohints' to the following line:

ExecStart=-/sbin/agetty ....

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


If you use KDM as a login manager, add:

numlockx on

to the /usr/share/config/kdm/Xsetup, or the /opt/kde/share/config/kdm/Xsetup for KDM3.

Note that this file will be overwritten on update without creating a .pacnew file. To prevent this, add the following line to /etc/pacman.conf file (omit the leading slash in the path):

NoUpgrade = usr/share/config/kdm/Xsetup

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.

Alternate Method

Alternatively, add the script the ~/.kde4/Autostart/ containing:

numlockx on

And make it executable:

$ chmod +x ~/.kde4/Autostart/

Alternate Method 2

This method enables num lock in KDM login screen (e.g. numeric password)

1) Disable "Themed Greeter" in System Settings -> Login Screen

2) in file /usr/share/config/kdm/kdmrc find section


Right after that line, add this:



First make sure that you have numlockx (from extra) installed then add the following code to /etc/gdm/Init/Default:

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 numlockx from the official repositories. 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"/>


In the file /etc/sddm.conf, add the following line under the [General] section:



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.


In the file /etc/lxdm/lxdm.conf uncomment the line:


and change to: