You are not logged in.

#1 2022-08-28 12:06:35

diogobaeder
Member
Registered: 2012-01-02
Posts: 59

[SOLVED] NumLock led not enabled after suspend

Hi folks,

This issue started happening to me months ago; It's not critical, which is the reason I'm only posting about this now, but it's kind of annoying. What's happening is that I use NumLock enabled all the time, but after I suspend my computer, and then wake it up, the NumLock led is turned off - even though the feature itself is turned on, which can be seen by the numbers I type and by command-line:

 $ xset q | grep -i num
    00: Caps Lock:   off    01: Num Lock:    on     02: Scroll Lock: off

So in the end what I have to do is to press it twice - once for disabling it, which keeps the led off, and a second time to turn both the feature and the led on again. No big deal, but mildly annoying anyway and I wish to fix it.

Any ideas? Here are my specs:

 $ uname -r
5.19.4-arch1-1
 $ lsusb | grep -i key
Bus 002 Device 003: ID 046d:c31c Logitech, Inc. Keyboard K120

Thanks!

Last edited by diogobaeder (2022-09-16 00:25:12)

Offline

#2 2022-08-28 13:08:48

koffeinfriedhof
Member
Registered: 2017-11-30
Posts: 89

Re: [SOLVED] NumLock led not enabled after suspend

Hi!

So just the led is disabled? You could manually enable it. The "official way" could be writing a libinput quirk for your keyboard model. The dirty way is simply enabling it with echo/tee (needs root permission). Look up the folder in /sys/class/leds, e.g. /sys/class/leds/input2::numlock and set the brightness to 1: `echo 1 > /sys/class/leds/*numlock/brightness`. For simpler usage you could use the brightnessctl-tool.

Offline

#3 2022-08-29 02:40:30

diogobaeder
Member
Registered: 2012-01-02
Posts: 59

Re: [SOLVED] NumLock led not enabled after suspend

koffeinfriedhof wrote:

Hi!

So just the led is disabled? You could manually enable it. The "official way" could be writing a libinput quirk for your keyboard model. The dirty way is simply enabling it with echo/tee (needs root permission). Look up the folder in /sys/class/leds, e.g. /sys/class/leds/input2::numlock and set the brightness to 1: `echo 1 > /sys/class/leds/*numlock/brightness`. For simpler usage you could use the brightnessctl-tool.

Exactly, only the led is off, the numbers work just fine though. And indeed the kernel recognizes the led as off:

 $ cat /sys/class/leds/input2::numlock/brightness
0

Using brightnessctl seems like a straightforward tool to turn it back on in an automated way, but first I'd like to try to find out why the led isn't being turned on, so that I don't have to write any workaround if possible... what is the facility that controls the turning off and on of special keys when the system is suspended?

Offline

#4 2022-08-29 08:35:24

koffeinfriedhof
Member
Registered: 2017-11-30
Posts: 89

Re: [SOLVED] NumLock led not enabled after suspend

That depends on a lot if stuff. Afair the way is like so: hardware → kernel input core (abstraction for usb,ps2,...)  / input→ device driver → event driver.
You can ignore the input core, but have to check the device driver (atkbd.c for ps/2, hid_generic for default usb, etc.) and the rules applied by udev/libinput. libinput invented quirks which are like udev rules but in another abstraction. On laptops often the i2c controller takes part in it, but that should be ignorable in this case.

I'm sure there is a simpler way, but this one is the one I know:

# check general keyboard informations, like the sysfs-path
grep -A4 -B8 120013 /proc/bus/input/devices
# sysfspath: only 
sysfspath=$(grep -A4 -B8 120013 /proc/bus/input/devices | awk -F= '/S: Sysfs/ {print $2}')
# bus and driver 
cat /sys/$(grep -A4 -B8 120013 /proc/bus/input/devices | awk -F= '/S: Sysfs/ {print $2}')/../../uevent

# udev:
udevadm info /sys/$sysfspath
udevadm info /sys/${sysfspath/input*/}

# example for all udev information
SYSTEMD_LOG_LEVEL=debug udevadm test /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:046D:C328.0002

# example hwdb: udev uses the hwdb for additional workarounds using the MODALIAS
systemd-hwdb query hid:b0003g0001v0000046Dp0000C328

# quirks: the libinput-hwdb-replacement/addition:
libinput quirks list /dev/input/eventX

(sorry for the dirty driver and path extraction, just copypasted the command wink )

You now should know the device driver and every rule applied for your keyboard. I never needed such stuff but you can easily add rules to hwdb like so:
Create: `/etc/udev/hwdb.d/61-mykeyboard.hwdb` with content
hid:{modalias}
  KEYBOARD_LED_NUMLOCK=0

or

evdev:atkbd:{modalias}


See /usr/lib/udev/hwdb.d/60-keyboard.hwdb for a lot of examples.
For the "new" libinput quirks see https://wayland.freedesktop.org/libinpu … ice-quirks

This was the basic stuff to check. After that it depends on your desktop environment as e.g. GNOME and Plasma do override such things with custom rules in their systemsettings.
I never tried such a rule in real life tbh.

In case of atkbd there are also some bootoptions to test and there are some quirks/rules in the atkbd.c itself which are not shown by above command.

Offline

#5 2022-08-29 11:05:01

diogobaeder
Member
Registered: 2012-01-02
Posts: 59

Re: [SOLVED] NumLock led not enabled after suspend

Thanks a lot, man! I'll give all that a go :-)

Will update here once I have news. Cheers!

Offline

#6 2022-09-16 00:27:53

diogobaeder
Member
Registered: 2012-01-02
Posts: 59

Re: [SOLVED] NumLock led not enabled after suspend

Alright, issue solved, but in a slightly different way:

1. First thing I enabled numlock at early startup, with mkinitcpio-numlock, as explained here: https://wiki.archlinux.org/title/Activa … kinitcpio)
2. Then, I also enabled it in GNOME, as explained here: https://wiki.archlinux.org/title/Activa … otup#GNOME

Looks like the steps above were enough for me - not sure exactly which one of them actually solved the issue, but since I never really use my keyboard with numlock off, I just made sure to always enable it.

Thanks!

Offline

Board footer

Powered by FluxBB