Turn off keyboard backlight when shutting down Linux

3

1

I bought a backlit keyboard a few days ago, and I have a problem with it:

  • When I shut down my PC from Linux, the keyboard backlight stays on after the PC turns off,
  • but when I shut down my PC from Windows, the backlight turns off.

How can I power off the keyboard when shutting down through Linux? My only way of accomplishing this right now is by manually using my fn key to turn off the backlight, and then using it again to turn the backlight back on after powering on the PC.

I'm not sure how relevant this is, but my Motherboard is Gigabyte F2A88XM-D3H and my keyboard is Metoo Zero (the backlit one with numpad and red switches).

Bosko Sinobad

Posted 2017-08-24T22:28:50.920

Reputation: 31

I'm not sure how relevant this is, but my Motherboard is Gigabyte F2A88XM-D3H, and my keyboard is Metoo Zero (the backlit one with numpad and red switches) – Bosko Sinobad – 2017-08-24T23:08:27.903

Have you installed drivers under Windows? if yes, find them for linux, maybe there are compatible ones. If not, maybe linux keeps USB active, while Windows turns off the USB completely and the LEDs are only a side effect. – FarO – 2017-08-25T07:35:54.800

Answers

1

In my Kubuntu the right place is /sys/class/leds/.

# ls /sys/class/leds/
dell::kbd_backlight  input4::capslock  input4::numlock  input4::scrolllock  phy0-led  xpad0

Most certainly, if your Metoo Zero backlight is there, it will be something other than dell::kbd_backlight, so the below commands are just examples.

# ls "/sys/class/leds/dell::kbd_backlight"
brightness  device  max_brightness  power  start_triggers  stop_timeout  subsystem  trigger  uevent
# cat "/sys/class/leds/dell::kbd_backlight/max_brightness"
2

This number suggests my backlight has three states. I can run (as root):

# echo 0 > "/sys/class/leds/dell::kbd_backlight/brightness"
# echo 1 > "/sys/class/leds/dell::kbd_backlight/brightness"
# echo 2 > "/sys/class/leds/dell::kbd_backlight/brightness"

It turned out the states are: 0=off, 1=dimmed, 2=bright.

If it works for you, make your Linux execute the appropriate command before it shuts down (I believe the way to do it is distribution-dependent).

Kamil Maciorowski

Posted 2017-08-24T22:28:50.920

Reputation: 38 429

There are a few things in there, but capslock, scrolllock and numlock are the only entries from my keyboard. The device/capabilities/led of my keyboard is set to 7, but I haven't had any luck in changing it. When I manually change the backlight settings through the keyboard, the led file stays on 7. – Bosko Sinobad – 2017-08-25T11:36:58.820

@BoskoSinobad I did some research. In my case the kernel module dell_laptop is responsible; dell::kbd_backlight disappears after rmmod dell_laptop and reappears after modprobe dell_laptop. I think you lack a driver. – Kamil Maciorowski – 2017-08-25T13:57:10.460

0

Without knowing the PC type it is hard to answer. Usually the leds are controlled through "dummy" files in /proc/acpi. For instance on my Lenovo, there is a /proc/acpi/ibm/kbdlight. The default contents are:

status:         0
commands:       0, 1, 2

The commands line means that you can write (as root) to the pseudo file:

echo 1 >/proc/acpi/ibm/kbdlight

So shutting off the lights would just require executing echo 0 >/proc/acpi/ibm/kbdlight in some script executed at shutdown.

xenoid

Posted 2017-08-24T22:28:50.920

Reputation: 7 552

wakeup is the only thing I have in /proc/acpi. I also had a look in /sys/class/leds and /sys/devices, but I had no luck in finding anything useful. – Bosko Sinobad – 2017-08-24T23:02:22.827