15

I have been using Ubuntu since 16.04, with the CM Storm keyboard. When using this keyboard on Windows, pressing the Scroll Lock key enables/disables the backlight.

Previously on Ubuntu, the commands xset led (on) and xset -led (off) have worked to set the backlight. This is pretty important because the key labels are very hard to read without the backlight enabled.

Now that Ubuntu has switched from X to Wayland by default with 17.10, xset no longer works. While I can make it work by selecting an Xorg session on login, I'd like to use the default and what will be the future of Ubuntu, Wayland.

What I'm looking for are some terminal commands that accomplish the same function as xset led and xset -led.

8
  • 2
    As you know Wayland is not X , so many x functions / programs do not work. xrandr for example. You need to file a bug report / feature request with wayland. You can fall back to x (log into gnome with an X session).
    – Panther
    Oct 22, 2017 at 3:45
  • FYI I would like to mention that xrandr works fine on my machine. $ xrandr "Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192 XWAYLAND0 connected 1440x900+0+0 (normal left inverted right x axis y axis) 0mm x 0mm 1440x900 59.89*+"
    – Rolf
    Oct 23, 2017 at 13:38
  • @Rolf does "works fine" mean you can switch to a different resolution, add new video modes, set up panning, DPI etc.?
    – Ruslan
    Nov 11, 2017 at 10:37
  • @Ruslan It seems only the commands that query some state do work. You are right.
    – Rolf
    Nov 11, 2017 at 16:32
  • Related: ask.fedoraproject.org/en/question/97720/… and reddit.com/r/linux_gaming/comments/51mdum/… – maybe try the xinput method mentioned in the latter?
    – dessert
    Nov 20, 2017 at 20:36

2 Answers 2

9

I also struggled with this and finally came up with a solution:

https://gist.github.com/ps1dr3x/b15c62eafb388ddf8bb7d3896d1a1cee

Basically you can turn on/off the keyboard backlight by changing the brightness value in /sys/class/leds/input/brightness

e.g.

sudo sh -c 'echo 1 > /sys/class/leds/input0::scrolllock/brightness'

P.s. input might be different

3
  • it's an hassle to have to login as root to do it + many keyboard keys (or at least capslock) switch it off... backlight is a peripheral setting not a system setting so it feels more like a dirty hack than a true solution. but thanks better than nothing obviously & let's hope wayland guys will do stg about it. lost 2 hours on setting tablet & keyboard moving from xorg to wayland...
    – mikakun
    Nov 3, 2022 at 19:27
  • 1
    yes I surely agree this is more a workaround. I noticed however this problem exists only with certain keyboards (also the fact that caps lock and/or other keys switch the lights off). Since I posted this answer I used various keyboards and never found the exact same behavior: some keyboards just have the leds always on, others have a key or combination of keys to control the lights, others don't switch off when pressing certain keys. Regarding root, I remember at the time I just set a root cronjob setting that flag every X seconds, kind of solving the switch off problem too.
    – Michele
    Nov 6, 2022 at 18:22
  • yep so true ! i just got a new keyboard & the backlight is working out of the box (on ubuntu wayland & fedora)
    – mikakun
    May 23 at 17:12
0

The device name seems to change on every reboot for me, thus I borrowed the last answer and provided the work around below.

*Unless you use more than one keyboard, then it in theory should work. Until of course it doesn't.

*On the downside if you do have more than one keyboard, it will just turn on the backlight LED for all keyboards? (Perhaps you could use the device ID and always get it right)

--Turns on the little backlight leds

cd /sys/class/leds
for i in `ls /sys/class/leds | grep scrolllock`; do echo 1 > $(readlink -f $i)/brightness; done;

--Turns off the little backlight leds

cd /sys/class/leds
for i in `ls /sys/class/leds | grep scrolllock`; do echo 0 > $(readlink -f $i)/brightness; done;

--Shows the full device directory including the device id, group exc.

cd /sys/class/leds
for i in `ls /sys/class/leds | grep scrolllock`; do echo $(readlink -f $i)/brightness; done;

--Easiest way to view the USB Device ID . ( Note: bus number may change. )

--With the ID , you can filter what is handled in the loop

lsusb

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .