Every time we switch on a classroom computer running Debian with the Plasma desktop, the numeric keypad starts switched off. Students type their password using the numbers on the right, nothing appears, and they have to press Num Lock before trying again. It’s a small thing, but across twenty computers several times a day it gets annoying. Let’s see how to leave it on by default, both on the login screen and inside the desktop.

Download the files
- activar-numlock.sh: script to run on a single computer.
- numlock-aula.yaml: Ansible playbook to set up the whole classroom at once.
Why one setting isn’t enough
NumLock has to be turned on at two different moments:
- On the login screen (SDDM), which is where the password is typed.
- In the Plasma session, which may reset the keyboard state when it starts.
On top of that, Debian 13 starts Plasma on Wayland by default, and the classic numlockx tool doesn’t work there: it only works in X11 sessions. That’s why the script does four things, so it works in every case.
What the script does
- Installs
numlockx, the small utility that turns NumLock on under X11. - Configures SDDM by creating
/etc/sddm.conf.d/numlock.confwith the optionNumlock=on, so the keypad is already on at the login screen. - Creates a system-wide autostart entry in
/etc/xdg/autostart/numlockx.desktop, which runsnumlockx onwhenever any user logs into an X11 session. - Sets Plasma’s default value in
/etc/xdg/kcminputrcwithNumLock=0in the[Keyboard]section. Plasma reads0as “turn on at startup” (1is off and2leaves it unchanged). This is the part that also works on Wayland.
Since everything is stored under /etc, the setting applies to every user on the computer, including users created later.
The script
Download it from the link at the top (activar-numlock.sh) or copy its contents into a file with the same name (the script’s messages are in Galician):
#!/bin/bash
# Activa o NumLock por defecto (pantalla de inicio SDDM + sesión KDE/X11)
# Equivalente local do playbook de Ansible da aula.
# Uso: sudo bash activar-numlock.sh
set -e
if [ "$(id -u)" -ne 0 ]; then
echo "Este script debe executarse como root: sudo bash $0" >&2
exit 1
fi
echo "[1/4] Instalando numlockx..."
apt-get update -qq
apt-get install -y numlockx
echo "[2/4] Configurando SDDM (pantalla de inicio)..."
install -d -m 0755 /etc/sddm.conf.d
cat > /etc/sddm.conf.d/numlock.conf <<'EOF'
[General]
Numlock=on
EOF
chmod 0644 /etc/sddm.conf.d/numlock.conf
echo "[3/4] Creando autostart global (numlockx on ao iniciar sesión)..."
cat > /etc/xdg/autostart/numlockx.desktop <<'EOF'
[Desktop Entry]
Type=Application
Name=Activar NumLock Aula
Exec=numlockx on
Icon=keyboard
NoDisplay=true
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
EOF
chmod 0644 /etc/xdg/autostart/numlockx.desktop
echo "[4/4] Valor por defecto de KDE Plasma (tamén funciona en Wayland)..."
# NumLock=0 -> activado ao iniciar Plasma (1 = desactivado, 2 = sen cambios)
if [ -f /etc/xdg/kcminputrc ] && grep -q '^\[Keyboard\]' /etc/xdg/kcminputrc; then
sed -i '/^\[Keyboard\]/,/^\[/{/^NumLock=/d}' /etc/xdg/kcminputrc
sed -i '/^\[Keyboard\]/a NumLock=0' /etc/xdg/kcminputrc
else
printf '\n[Keyboard]\nNumLock=0\n' >> /etc/xdg/kcminputrc
fi
# Activalo xa na sesión actual, se hai unha sesión X aberta
if [ -n "$SUDO_USER" ] && [ -n "$DISPLAY" ]; then
sudo -u "$SUDO_USER" DISPLAY="$DISPLAY" numlockx on 2>/dev/null || true
fi
echo "Feito: NumLock configurado en $(hostname). Pecha sesión ou reinicia para comprobalo."
How to run it
Open a terminal (Konsole) and go to the folder where you saved the file. For example, if you left it in Downloads:
cd ~/Downloads
First give it execute permission, so the system treats it as a program rather than a plain text file:
chmod +x activar-numlock.sh
You can check it has the permission with ls -l activar-numlock.sh: there should be an x at the start of the line, for example -rwxr-xr-x.
Now run it as administrator with sudo, because it changes system files in /etc and installs a package:
sudo ./activar-numlock.sh
The leading ./ means the script is in the current folder. It will ask for your password and show steps 1 to 4 as it goes. If you run it without sudo, the script itself warns that it must run as root and does nothing.
When it finishes, log out or restart the computer. The keypad should already be on at the login screen, and it will stay on once you’re in the desktop.
If a user still has NumLock off
The /etc/xdg/kcminputrc file only sets the default value. If a user changed this option before, their personal settings (~/.config/kcminputrc) take priority. In that case, go to System Settings → Keyboard and set NumLock on Plasma Startup to Turn on. You can also delete the NumLock= line from that personal file so it picks up the system value again.
What if you have many computers? Use Ansible
If you manage the classroom with Ansible, there’s no need to go computer by computer: the playbook numlock-aula.yaml applies the setting to all of them at once from the teacher’s computer.
---
- name: Configurar e activar NumLock permanente na aula
hosts: aula
remote_user: root
gather_facts: no # Non necesitamos recoller facts, asà vai máis rápido
tasks:
- name: Instalar numlockx para asegurar o control do teclado
apt:
name: numlockx
state: present
update_cache: yes
- name: Asegurar que o directorio de configuración de SDDM existe
file:
path: /etc/sddm.conf.d
state: directory
mode: '0755'
- name: Configurar SDDM para activar NumLock na pantalla de inicio
copy:
dest: /etc/sddm.conf.d/numlock.conf
content: |
[General]
Numlock=on
mode: '0644'
- name: Crear activación forzada no Autostart global do sistema
copy:
dest: /etc/xdg/autostart/numlockx.desktop
content: |
[Desktop Entry]
Type=Application
Name=Activar NumLock Aula
Exec=numlockx on
Icon=keyboard
NoDisplay=true
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel
mode: '0644'
- name: Valor por defecto de KDE Plasma (NumLock activado, tamén en Wayland)
ini_file:
path: /etc/xdg/kcminputrc
section: Keyboard
option: NumLock
value: '0' # 0 = activado, 1 = desactivado, 2 = sen cambios
no_extra_spaces: yes
mode: '0644'
- name: Notificar fin do proceso
debug:
msg: "Configuración do NumLock aplicada e persistente en {{ inventory_hostname }}"
To use it you need an inventory with a group called aula and SSH access as root to the computers. For example, a file called inventario:
[aula] pc01 pc02 pc03
Then run it like this (the .yaml file doesn’t need execute permission, because Ansible reads it):
ansible-playbook -i inventario numlock-aula.yaml
The playbook does the same four steps as the script, including the /etc/xdg/kcminputrc one, so it works the same in X11 and Wayland sessions. It uses the ini_file module, which comes with the usual Ansible install (Debian’s ansible package).