Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Software] Programmatically enable Numlock key on boot?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
Enigma83
Posts: 93
Joined: 2024-01-03 08:03
Location: Deep space
Been thanked: 3 times

[Software] Programmatically enable Numlock key on boot?

#1 Post by Enigma83 »

Forgive me if "programmatically" isnt the right term here. Perhaps "automatically" would be more appropriate, but whatever. Anyway, I have a Dell XPS 13 9360. The internal keyboard doesnt have a Numlock key. However, about a week ago I bought an RGB mechanical keyboard, Redragon K556 Pro Wireless, which supports connecting via wired/Bluetooth/wireless 2.5ghz USB dongle chip. I'm really liking it and dont want to return it. It has excellent compatibility with Debian, Windows, and my Playstation 5.

However, I've noticed that the Numlock key isnt always enabled after rebooting, I can tell it's off just by looking at the light above it (or lack of a light, if disabled). I'm not sure if this is a quirk of this keyboard, or if it's just something that's common behavior on mechanical keyboards. And while it's no big deal to just tap the button, I'd rather it always be enabled automatically. Perhaps by editing a config file, having a script autorun on every boot, whatever. I use the keyboard in wired mode most of the time, it's easily identifiable with the lsusb command, perhaps there is a way to use its' "identifier" to recognize the device and auto toggle the Numlock to be on. And in the cases where it's not connected on Debian boot, but instead manually connected to the laptop at whatever time, maybe a script that polls, say, once per minute until the keyboard is detected and toggles the key to be on.

Thanks!

reinob
Posts: 1198
Joined: 2014-06-30 11:42
Has thanked: 100 times
Been thanked: 47 times

Re: [Software] Programmatically enable Numlock key on boot?

#2 Post by reinob »

you can use the numlockx program (apt install numlockx) and run "numlockx on" in one of your initialization scripts.
I have that in my .xsessionrc.

Enigma83
Posts: 93
Joined: 2024-01-03 08:03
Location: Deep space
Been thanked: 3 times

Re: [Software] Programmatically enable Numlock key on boot?

#3 Post by Enigma83 »

reinob wrote: 2024-04-06 07:13 you can use the numlockx program (apt install numlockx) and run "numlockx on" in one of your initialization scripts.
I have that in my .xsessionrc.
Thanks for the reply. But I ideally want to enable it immediately after the kernel boots. And hopefully it would remain on, unless I manually press the button, or use a software like numlockx to toggle it. I'm not sure if it would remain on while in a TTY.

arzgi
Posts: 1203
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 34 times

Re: [Software] Programmatically enable Numlock key on boot?

#4 Post by arzgi »

I have also used numlockx, works well in X, but to enable right on boot, check first the BIOS/UEFI settings, most of my computers as this laptop have option to set numlock on.

Enigma83
Posts: 93
Joined: 2024-01-03 08:03
Location: Deep space
Been thanked: 3 times

Re: [Software] Programmatically enable Numlock key on boot?

#5 Post by Enigma83 »

arzgi wrote: 2024-04-06 08:04 I have also used numlockx, works well in X, but to enable right on boot, check first the BIOS/UEFI settings, most of my computers as this laptop have option to set numlock on.
This option does exist in my BIOS, and it's enabled (was already enabled long before I bought a mechanical keyboard). However, as I've already said in the 1st post, the laptop's internal keyboard doesn't have a NumLock key, so it doesn't make any sense for this option to be in my BIOS.

arzgi
Posts: 1203
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 34 times

Re: [Software] Programmatically enable Numlock key on boot?

#6 Post by arzgi »

Enigma83 wrote: 2024-04-06 08:23
arzgi wrote: 2024-04-06 08:04 I have also used numlockx, works well in X, but to enable right on boot, check first the BIOS/UEFI settings, most of my computers as this laptop have option to set numlock on.
This option does exist in my BIOS, and it's enabled (was already enabled long before I bought a mechanical keyboard). However, as I've already said in the 1st post, the laptop's internal keyboard doesn't have a NumLock key, so it doesn't make any sense for this option to be in my BIOS.
Same here, but tested by connecting a keyboard to the laptop's usb port, and Numlock on led lights at boot. I found also a lot of discussion of the topic when searched, but I think this is the simplest method. I have no bluetooth keyboard to test.

DeBonzo
Posts: 8
Joined: 2022-03-12 23:54

Re: [Software] Programmatically enable Numlock key on boot?

#7 Post by DeBonzo »

You could put something in /etc/default/keyboard XKBOPTIONS="" except I'm not sure if there's a specific option to switch numlock on, unless I've missed it. Have a look in the bottom of file /usr/share/X11/xkb/rules/base for the many options. These settings work before X is started despite the X11 connection. In fact when I put "caps:none" in /etc/default/keyboard it didn't work because it was being overridden by the desktop. So you might have to implement two solutions.

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 666
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 88 times
Been thanked: 110 times

Re: [Software] Programmatically enable Numlock key on boot?

#8 Post by wizard10000 »

we see things not as they are, but as we are.
-- anais nin

Enigma83
Posts: 93
Joined: 2024-01-03 08:03
Location: Deep space
Been thanked: 3 times

Re: [Software] Programmatically enable Numlock key on boot?

#9 Post by Enigma83 »

I did read somewhere that X11 has something to do with NumLock. Previously (no longer), I was running LXQT with the SDDM display/login manager. When powering on, I could see my external keyboard's NumLock light self-activate, which seemed to imply that the BIOS setting was doing its' job. It remained on during the transition from GRUB to the login screen. Once you reach this point you have gone from real mode to protected mode, the OS is in full control, and the BIOS plays a minimal role in the background. But once I logged in, I noticed that NumLock immediately turned off. I suspect that X11 has something to do with switching it off, or on. LXQT has a setting that can enable NumLock after logging in, but that is of course DE-specific and not generally useful outside of LXQT.

User avatar
sunrat
Administrator
Administrator
Posts: 6593
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 119 times
Been thanked: 502 times

Re: [Software] Programmatically enable Numlock key on boot?

#10 Post by sunrat »

KDE Plasma has under the Keyboard section of Settings:
- Turn on
- Turn off
- Leave unchanged

I guess "Leave unchanged" retains the BIOS setting.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Enigma83
Posts: 93
Joined: 2024-01-03 08:03
Location: Deep space
Been thanked: 3 times

Re: [Software] Programmatically enable Numlock key on boot?

#11 Post by Enigma83 »

sunrat wrote: 2024-05-04 00:32 KDE Plasma has under the Keyboard section of Settings:
- Turn on
- Turn off
- Leave unchanged

I guess "Leave unchanged" retains the BIOS setting.
But I'm not using KDE, or any DE, so it's irrelevant. You basically just backed up what I've already said, that certain DEs can have their own options to override/change NumLock behavior. But it's not useful outside that DE's context.

User avatar
sunrat
Administrator
Administrator
Posts: 6593
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 119 times
Been thanked: 502 times

Re: [Software] Programmatically enable Numlock key on boot?

#12 Post by sunrat »

Enigma83 wrote: 2024-05-04 01:05You basically just backed up what I've already said,
You're welcome! :D

Did the Arch wiki link posted by wizard10000 help at all?
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Post Reply