Skip to content

Instantly share code, notes, and snippets.

@ps1dr3x
Created October 26, 2018 17:44
Show Gist options
  • Save ps1dr3x/b15c62eafb388ddf8bb7d3896d1a1cee to your computer and use it in GitHub Desktop.
Save ps1dr3x/b15c62eafb388ddf8bb7d3896d1a1cee to your computer and use it in GitHub Desktop.
Turn on keyboard backlight/leds on wayland (xset led 3 alternative)
# "input0::scrolllock" might be different (?)
# On
sudo sh -c 'echo 1 > /sys/class/leds/input0::scrolllock/brightness'
# Off
# sudo sh -c 'echo 0 > /sys/class/leds/input0::scrolllock/brightness'
@ps1dr3x
Copy link
Author

ps1dr3x commented Oct 30, 2021

@Magnitudexx hmm weird, no idea. Maybe there are other paths, you could try searching for other ones.
@MrGeodude I had the same problem with one keyboard. I just set a cronjob writing the bit every few seconds, worked just fine (apart from the few seconds off).

@NGR-NP
Copy link

NGR-NP commented Apr 24, 2022

echo 1 | sudo tee /sys/class/leds/input12::scrolllock/brightness

This work for but the 2 input folder with scrollock and the name is static but the number keep changing on 2 days it changes 3 times first its was input12::scrolllock and 2 was input3::scrolllock but after 12 hour it change to 36 and 43 and again next day it return on to same as first time input12::scrolllock and input3::scrolllock

@baalbvip
Copy link

Encontraron alguna solucion?, cuando presiono Block mayus, o numeral se me apaga.

@baalbvip
Copy link

Esto funciona perfectamente, pero cuando presiono el bloqueo de mayúsculas o la tecla de bloqueo numérico, mis luces de fondo se apagan nuevamente. ¿Hay alguna forma de configurarlos para que se enciendan de forma permanente?

Encontraste solucion?

@Tryware
Copy link

Tryware commented Jul 16, 2022

@Magnitudexx The brightness file just rewrites the value inside, it doesn't matters if you try changing it with echo or directly with a text editor. I don't know what's preventing it to change tho.

@aevim
Copy link

aevim commented Jul 18, 2022

I also have the same problem.. It gets overwrite to 0 again after I changed it to 1, so the keyboard just blinks.

@ps1dr3x
Copy link
Author

ps1dr3x commented Jul 20, 2022

Hmm.. Maybe you have a daemon or something else running and rewriting the value @aevim @Tryware, maybe you could try to monitor the i/o operations on that path. I guess the behavior of this operation is also dependent on the keyboard's hardware, firmware and drivers. I changed keyboard and I don't need this workaround anymore, but in my case for example I had to put that in a 5 seconds cronjob because for some reasons the value was rewritten to 0 every time I was pressing the CapsLock key (but only in that case as far as I remember).

@Longcoming
Copy link

how to learn the input device?

@alejrot
Copy link

alejrot commented Jun 22, 2024

I've made a Systemd task to detect and force the LEDs to turn on periodically.
There's the repository

@Soumyaranjan-17
Copy link

for some reason this only blinks the led for me, any thoughts?

Because that file 'inputX::scrolllock' changes always, in my case the number was input23::scrolllock first then it changes to input26::scrolllock, after when i run the command 'sudo sh -c 'echo 1 > /sys/class/leds/inputX::scrolllock/brightness'
'

@zero-stacks
Copy link

zero-stacks commented Nov 3, 2024

well guys i had this problem on many recent linux distros, on fedora 40 it used to work fine by default but fedora 41 doesn't anymore, decided to make my own script/systemd service to monitor the brightness file under the scroll lock device and change value to 1

check it here: https://github.com/zero-stacks/ScrollLock_Monitor_Service
it's well explained and detailed

@zero-stacks
Copy link

for some reason this only blinks the led for me, any thoughts?

Because that file 'inputX::scrolllock' changes always, in my case the number was input23::scrolllock first then it changes to input26::scrolllock, after when i run the command 'sudo sh -c 'echo 1 > /sys/class/leds/inputX::scrolllock/brightness' '

changing manually wont help cuz for some reason it resets back to 0 whenever you press capslock or numlock this is why i made a systemd service to check the file every 2 secs, it is resourceless and harmless, works very well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment