Skip to content

A Python script to activate the Scroll Lock LED (the backlight in some keyboards)

License

Notifications You must be signed in to change notification settings

bigrand/scrolllock-wlroots-workaround

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

scrolllock-wlroots-workaround

A workaround to activate Scroll Lock LED (the backlight in some keyboards) in wlroots based compositors.

According to this swaywm/sway#5342 (comment), the LEDs appear to be updated post-key-release regardless of the key, which causes the backlight to be disabled immediately after turning it on. LEDs now only update when a LED changes. A workaround is still needed though.

If you are using GNOME/Mutter you can use these workarounds in combination with the first workaround in this repo.

Related issues and links:

Issue on Gitlab | Backlight activated by the Scroll Lock LED can't be turn on

Merge request on Gitlab | types/wlr_keyboard.c : keyboard_led_update when leds is change (Merged)

libinput/issue #11 | scrolllock, the only key that can switch keyboard back light can't be activated

libinput/issue #102 | Scroll Lock doesn't work as expected

Reddit | I can't enable Scroll Lock to turn keyboard's LED lights [Devastador 2 Gaming Keyboard]

Workarounds

The python script workaround gives the same results as using xset led named "Scroll Lock" in Xorg, but requires executing a python script and executing it as root. This script should also work on GNOME/Mutter (untested).

Since the second "workaround" got merged, there's not need to patch wlroots anymore. I still recommend using the python script to prevent the CapsLock and NumLock from turning off the LED

Workaround - Python script

Download it here.

Requires to run the script with admin-level access. (It reads from /dev/input/event and /sys/class/leds/)

This script is based on libinput/examples/led-toggle.py

Dependencies

libevdev

Execution steps

After installing the necessary packages and modules, and downloading the script. You can proceed to execute it.

Usage

python ledToggler.py <path> <keystr> <ledstr> <forceLed> <startLed>

If you just want to enable your scroll lock LED use and toggle it as you want, then use: python ledToggler.py /dev/input/eventX scrolllock scrolllock 1 1

Replace X with your keyboard's handle event number. You can check it using: cat /proc/bus/input/devices

Arguments/Options explanation

<path> refers to the event path of your keyboard. dev/input/eventX

<keystr> refers to the name of the toggle key. numlock, capslock, scrolllock

<ledstr> refers to the name of the LED that you want to toggle. numlock, capslock, scrolllock

<forceLed> when disabled it won't force the LED to stay on (susceptible to LEDs updates), when enabled it forces the LED to stay on unless the toggle key state is off. 0, 1

Important: <forceLed> is useful to have it enabled because when CapsLock or NumLock are pressed, the ScrollLock LED turns off. When enabled, visually, the LED doesn't turn off.

<startLed> when disabled upon execution the script won't turn on the LED, when enabled upon execution the script will turn on the LED. 0, 1

Commands to toggle the LED

You can use these commands to toggle the LED without the python script:

brightnessctl --device='*::scrolllock' set 1 # ON
brightnessctl --device='*::scrolllock' set 0 # OFF

# Alternative
sudo sh -c 'echo 1 > /sys/class/leds/inputX::scrolllock/brightness' # ON
sudo sh -c 'echo 0 > /sys/class/leds/inputX::scrolllock/brightness' # OFF

You can also use these workarounds to activate the LEDs.


About

A Python script to activate the Scroll Lock LED (the backlight in some keyboards)

Topics

Resources

License

Stars

Watchers

Forks

Languages