Deployment: How to activate the Numlock permanently? CLI or Script

Hi,
I am deploying Leap15.3 with KDE in my organization.

I need to activate the Numlock on every boot via CLI/Script. So that it is already on (numerical input instead navigation) after the boot.
This is the way to do it via GUI:

Settings / Input Devices/ Keyboard / Numlock at Plasma Start / The Radio BTNs 

This Settings corespondents to the file:

~/.config/kcminputrc

There is a Entry that saves the settings:

NumLock=0

0 is Enabled at boot
1 ist Disabled at boot
2 is don’t care

Unfortunately this modified file will not work after a reboot to set the Numlock on.

Any ideas to trigger this settings (like the GUI) via CLI?

Greetings and thanks,
Hendrik

You want to do this on boot. But you are looking at a solution in the KDE desktop. Thus you are looking in the wrong direction.

Sorry that I can not tell you how to set Numlock on boot, but what you are trying (setting something for a (each?) user that can/will/may login in the KDE desktop is IMHO not the way to a solution.

I gave up on getting numlock to work at boot.

It is easier and more useful to have it configured for when you login to KDE.

System Settings –> Input Devices

and the setting is right there (“Numlock on Plasma Startup”).

If using sddm, you can add:

cat /etc/sddm.conf.d/00-general.conf 
[XDisplay]
MinimumVT=7
# boo#1089932
EnableHiDPI=true

[General]
HaltCommand=
Numlock=on
RebootCommand=

[Users]
# boo#979775
ReuseSession=true
MaximumUid=65000
MinimumUid=1000

cli

numlockx on

I experimented a bit.

As user, logged in in the GUI, it “works”

But as root from the console there is the message “cannot open display”. Which confirms that the x in numlockx refers to the X environment.
And as you have no X environment during boot, I doubt this will help the OP in is queste to have it switched on during boot.

Following the suggestion of larryr, the package “numlockx” is suggested by “patterns-base-x11_enhanced” – meaning that most systems should have this KDE CLI tool available –


 > numlockx -h
NumLockX 1.2
(C) 2000-2001 Lubos Lunak <l.lunak@kde.org>
(C) 2001      Oswald Buddenhagen <ossi@kde.org>

Usage : numlockx [on|off]
on     - turns NumLock on in X ( default )
off    - turns NumLock off in X
toggle - toggles the NumLock on and off in X

 >

[HR][/HR]Suggestion for an “all users” deployment –

  1. Drop an executable script with a “.sh
    ” extension containing “/usr/bin/numlockx on” into ‘/home’. 1. In each user’s ‘~/.config/plasma-workspace/env
    ’ directory create a symbolic link to the “all users” executable ‘.sh’ script …

Have you checked the BIOS? Most of the devices I have bought have a default setting for NumLock, which may be On or Off. I have generally used KDE as described above if I wanted to change the default setting but there may be a BIOS setting or a BIOS option; for example, on my 2007 Dell notebook, holding down Fn during boot turns NumLock on (the default being Off).

NumLock on openSUSE should be done via YaST. It applies to both KDE and virtual console. It also survives restart.
*Yast2 -> Sysconfig Editor -> Hardware -> Keyboard -> KBD_NUMLOCK:yes

*CLI approach: /etc/sysconfig/keyboard: KBD_NUMLOCK=“yes”

CLI via YaST: # sudo yast sysconfig set KBD_NUMLOCK=yes

Mine have all been like what follows since somewhere around SuSE 8.0, and that it works is one of the reasons why I chose to stay with SuSE after first trying SuSE:

# diff -u /etc/sysconfig/keyboard01 /etc/sysconfig/keyboard
...
 ## Type:        list(bios,yes,no)
 ## Default:     bios
 #
 # NumLock on? ("yes" or "no" or empty or "bios" for BIOS setting)
 # This setting may interfere with GNOME /desktop/gnome/peripherals/keyboard/remember_numlock_state GConf key.
-KBD_NUMLOCK="bios"
+KBD_NUMLOCK="yes"
...
# grep NUM /etc/sysconfig/keyboard
KBD_NUMLOCK="yes"

Keyboard01 is the saved original file provided at installation. In addition, in each DE and DM I use and that has config options for NUM state, I find it and set keyboard state to on. For KDE Plasma, this is kept in ~/.config/kcminputrc:

...
[Keyboard]
...
NumLock=0
...

IMO it’s rude and absurd that the kernel doesn’t apply the NUM state from the BIOS by default instead of flipping it off every chance it gets.

Sorry, I was not very specific. There is only one KDE user active on every PC, so a user-specific setting is not required.

This does the trick for me:

CLI approach: **/etc/sysconfig/keyboard:** *KBD_NUMLOCK="yes"*

Thanks for all your time and knowledge.

Greetings from Germany,
Hendrik

Hmm – on this machine –

  • /etc/sysconfig/keyboard
    – KBD_NUMLOCK=“bios”

But, I must admit that, I also use –


 > cat /etc/sddm.conf.d/General.conf 
[General]
Numlock=on
 > 

  • because, ‘/usr/lib/sddm/sddm.conf.d/00-general.conf
    ’ doesn’t explicitly do it …