You are not logged in.

#1 2016-02-13 23:42:40

raul_l
Member
From: Amsterdam
Registered: 2014-11-04
Posts: 58

How to disable keyboard backlight from terminal?

I followed the keyboard backlight Python script at arch wiki but it doesn't work for me:

Traceback (most recent call last):
  File "./script.sh", line 25, in <module>
    print(kb_light_set(1)) # ./kb-light.py (+|--up) to increment
  File "./script.sh", line 11, in kb_light_set
    current = kbd_backlight.GetBrightness()
  File "/usr/lib/python3.5/site-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python3.5/site-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3.5/site-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "GetBrightness" with signature "" on interface "org.freedesktop.UPower.KbdBacklight" doesn't exist

I tried manually changing various parameters under /sys but could not find anything related to keyboard backlight. This is what I have:

$ ls /sys/class/leds
input0::capslock  input0::numlock  input0::scrolllock  phy0-led
$ ls /sys/devices/platform
ACPI0003:00  efi-framebuffer.0	pcspkr	    PNP0C0E:00	  serial8250
ACPI000C:00  i8042		PNP0C0A:00  PNP0C14:01	  uevent
alarmtimer   microcode		PNP0C0C:00  power	  vboxdrv.0
coretemp.0   MSFT0101:00	PNP0C0D:00  regulatory.0

The problem is that whenever I start the computer the backlight is on. I have to press Fn+F4 several times, to go through all the brightness levels, to turn it off, which is inconvenient.

When I press Fn or Fn+F4, xev registers nothing. It would be helpful if I knew what signal the keyboard is sending to the operating system when I press the brightness keys. I had a look at journalctl output but it displays nothing related to keyboard backlight. What else could I try?

If all else fails, I will open my laptop and see if I can disconnect something.

Last edited by raul_l (2016-02-13 23:43:32)


Raul Laasner

Offline

#2 2016-02-16 14:38:27

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: How to disable keyboard backlight from terminal?

Have you tried writing to /sys/class/leds/*/brightness, i.e. `echo 123 > file'?

Offline

#3 2016-02-16 18:15:11

TheSaint
Member
From: my computer
Registered: 2007-08-19
Posts: 1,523

Re: How to disable keyboard backlight from terminal?

I think it's depending on the model. I find the control over /sys/class/leds/asus\:\:kbd_backlight/brightness
What model's your laptop ?


do it good first, it will be faster than do it twice the saint wink

Offline

#4 2016-02-16 18:22:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: How to disable keyboard backlight from terminal?

raul_l wrote:

When I press Fn or Fn+F4, xev registers nothing. It would be helpful if I knew what signal the keyboard is sending to the operating system when I press the brightness keys.

That's because you are thinking about it backwards.  When you use firmware managed keys on the keyboard (e.g. for keyboard backlight) this signal is processed by the hardware/firmware before it goes to the OS.   When you hit other keys on the keyboard, the hardware sends signals to the OS that the OS can interpret - the OS doesn't tell hardware when keys were pressed.

But with the /sys/ filesystem, there often is another way to the OS to send signals to affect hardware.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-02-16 20:57:08

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: How to disable keyboard backlight from terminal?

Trilby wrote:

That's because you are thinking about it backwards.  When you use firmware managed keys on the keyboard (e.g. for keyboard backlight) this signal is processed by the hardware/firmware before it goes to the OS.   When you hit other keys on the keyboard, the hardware sends signals to the OS that the OS can interpret - the OS doesn't tell hardware when keys were pressed.

How is it then possible to swap the interpretation of the fn key?

Offline

#6 2016-02-16 21:25:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: How to disable keyboard backlight from terminal?

Respiranto, that is often done in bios settings.  That can be done by some software; that software sends a signal to affect the hardware (my second paragraph) telling the hardware to interpret the keys differently.  This doesn't affect my point: the interpretation of screen and/or keyboard backlight keys is handled by firmware.  The OS can interact with firmware to tell it to change backlight settings, but the OS would not send "keystrokes" to the firmware/hardware to do so - the key presses are sent from the hardware/firmware to the OS, not the other way around.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2016-02-16 21:28:53

chris_l
Member
Registered: 2010-12-01
Posts: 390

Re: How to disable keyboard backlight from terminal?

respiranto wrote:
Trilby wrote:

That's because you are thinking about it backwards.  When you use firmware managed keys on the keyboard (e.g. for keyboard backlight) this signal is processed by the hardware/firmware before it goes to the OS.   When you hit other keys on the keyboard, the hardware sends signals to the OS that the OS can interpret - the OS doesn't tell hardware when keys were pressed.

How is it then possible to swap the interpretation of the fn key?

Is not possible.

Well, I guess (not 100% sure about this) you could code your own firmware so the keyboard sends a code when the fn key is pressed, and then clone the linux source code, alter the keyboard driver, so the kernel sends the keyboard a signal that your custom firmware interprets as turning on/off the backlight (which I guess could be similar to the signal of the num lock thing)

But if you were willing to go as far as rewriting the firmware, then it would be easier to disassemble the current firmware, find out which part turns on the backlight at power on, alter it, and then write it back. All this is assuming that the firmware is stored on a regular PROM/EEPROM chip, and therefore, is possible that you alter it on the first place.

What Trilby meant, was that the op was thinking backwards, and should change his point of view of it, not that he should/could swap the interpretation of fn.


"open source is about choice"
No.
Open source is about opening the source code complying with this conditions, period. The ability to choose among several packages is just a nice side effect.

Offline

#8 2016-02-16 23:58:04

raul_l
Member
From: Amsterdam
Registered: 2014-11-04
Posts: 58

Re: How to disable keyboard backlight from terminal?

The laptop is an Oryx Pro from System76.

respiranto wrote:

Have you tried writing to /sys/class/leds/*/brightness, i.e. `echo 123 > file'?

Yes, no effect.

Trilby wrote:

signal is processed by the hardware/firmware

I had suspected that, in which case I guess there's no easy fix to this issue (I won't be modifying any firmware).

I've had backlit keyboards before, but usually the default setting is no brightness. I've never used backlighting.

Last edited by raul_l (2016-02-16 23:58:49)


Raul Laasner

Offline

#9 2016-02-17 00:21:33

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: How to disable keyboard backlight from terminal?

I wasn't trying to say there's no way to do it - there should be.  I was just clarifying that trying to see what keysyms the OS sees is not a productive strategy.  Exploring the /sys/ filesystem could be productive.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2016-02-17 00:51:32

raul_l
Member
From: Amsterdam
Registered: 2014-11-04
Posts: 58

Re: How to disable keyboard backlight from terminal?

It is possible though that it's entirely an internal keyboard feature with no possibility of controlling it from the OS, no? I've been trying everything I can think of under /sys but so far no luck. Maybe something will come up ...


Raul Laasner

Offline

Board footer

Powered by FluxBB