- Keyboard backlight
- Any vendor
- xset
- D-Bus
- On GNOME
- On MATE
- Arch Linux User Repository
- klore commented on 2018-06-07 13:58 (UTC)
- Arch Linux User Repository
- Package Details: brightness-controller-git 2.4.r9.gac79592-1
- Package Actions
- Dependencies (9)
- Required by (0)
- Sources (4)
- Latest Comments
- yochananmarqos commented on 2022-10-03 15:56 (UTC) (edited on 2022-10-03 15:56 (UTC) by yochananmarqos)
- peter.kehl commented on 2022-10-03 15:23 (UTC)
Keyboard backlight
There are various methods to control the keyboard backlight brightness level.
Any vendor
There are a variety ways to manage the brightness level and different helpers tools to accomplish this, such as brightnessctl or light .
The sys pseudo-file system exposes an interface to the keyboard backlight. The current brightness level can be get by reading /sys/class/leds/tpacpi::kbd_backlight/brightness . For example to get the maximum brightness level:
$ cat /sys/class/leds/tpacpi::kbd_backlight/max_brightness
To set the brightness to 1:
# echo 1 > /sys/class/leds/tpacpi::kbd_backlight/brightness
When using brightnessctl you can get a list of available brightness controls with brightnessctl —list , then to show the kbd backlight information:
$ brightnessctl --device='tpacpi::kbd_backlight' info
This will show the absolute and relative current value and the maximum absolute value. To set a different value:
$ brightnessctl --device='tpacpi::kbd_backlight' set 1
xset
Some keyboard manufactores are not recognized by brightnessctl or light , but you can use xorg-xset to control its lights if you are running Xorg.
The first parameter led turns on the led, and -led turns it off, the NUMBER parameters accepts integers for 1 to 32 (each number corresponds to a led in you system, keyboards seem to generally be number 3), or ‘on’ and ‘off’ (on will turn ALL lights on, and off will turn ALL lights off).
D-Bus
You can control your computer keyboard backlight via the D-Bus interface. The benefits of using it are that no modification to device files is required and it is vendor agnostic.
The following is an example implementation in Python 3. Install upower and dbus-python packages then place the following script in /usr/local/bin/ and make it executable. You can then map your keyboard shortcuts to run /usr/local/bin/kb-light.py + x and /usr/local/bin/kb-light.py — x to increase and decrease your keyboard backlight level by x amounts.
Tip: You should try with an x = 1 to determine the limits of the keyboard backlight levels
#!/usr/bin/env python3 import dbus import sys def kb_light_set(delta): bus = dbus.SystemBus() kbd_backlight_proxy = bus.get_object('org.freedesktop.UPower', '/org/freedesktop/UPower/KbdBacklight') kbd_backlight = dbus.Interface(kbd_backlight_proxy, 'org.freedesktop.UPower.KbdBacklight') current = kbd_backlight.GetBrightness() maximum = kbd_backlight.GetMaxBrightness() new = max(0, min(current + delta, maximum)) if 0Alternatively the following bash one-liner will set the backlight to the value specified in the argument:
On GNOME
The following can be run from a terminal or mapped to keybindings
$ gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Keyboard.StepUp $ gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Keyboard.StepDownOn MATE
This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.
In case you use MATE environment you might get tired with repeated lighting keyboard backlight while logging in, unlocking screen or waking up dimmed display. Following setup prevent from automatic lighting up during any action. The only triggers remain plugging in the adapter and fresh boot. After that you can control keyboard backlight only via hotkeys (eg. ThinkPad Fn + spacebar).
To prevent automatic lighting up just edit file /usr/share/dbus-1/system.d/org.freedesktop.UPower.conf as follows (two occurrences of "deny"):
/usr/share/dbus-1/system.d/org.freedesktop.UPower.confArch Linux User Repository
@klore: The path /sys/class/backlight/intel_backlight/max_brightness is currently hardcoded, and apparently does not exist on your system. I will look into this.
Edit: I tried to fix the problem. Does it build for you now? If not, could you please provide the output of ls /sys/class/backlight ?
klore commented on 2018-06-07 13:58 (UTC)
==> Starting build(). cat: /sys/class/backlight/intel_backlight/max_brightness: No such file or directory gcc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -Wextra -O3 -march=native -D BACKLIGHT_DIR=\"/sys/class/backlight/intel_backlight/\" -D MAX_BRIGHTNESS= backlight_control.c -o backlight_control backlight_control.c: In function ‘main’: backlight_control.c:39:39: error: invalid type argument of unary ‘’ (have ‘int’) brightness_value += MAX_BRIGHTNESS * value / 100; ^~~~~~~ backlight_control.c:42:38: error: invalid type argument of unary ‘’ (have ‘int’) brightness_value = MAX_BRIGHTNESS * value / 100; ^~~~~~~ backlight_control.c:13:26: error: expected expression before ‘)’ token #define MIN(a, b) ((a < b) ? a : b) ^ backlight_control.c:44:21: note: in expansion of macro ‘MIN’ brightness_value = MIN(brightness_value, MAX_BRIGHTNESS); ^~~ make: *** [Makefile:14: backlight_control] Error 1 ==>ERROR: A failure occurred in build(). Aborting.
Copyright © 2004-2023 aurweb Development Team.
AUR packages are user produced content. Any use of the provided files is at your own risk.
Arch Linux User Repository
Package Details: brightness-controller-git 2.4.r9.gac79592-1
Package Actions
Git Clone URL: | https://aur.archlinux.org/brightness-controller-git.git (read-only, click to copy) |
---|---|
Package Base: | brightness-controller-git |
Description: | Control Brightness of your Primary and Secondary Display in Linux |
Upstream URL: | https://github.com/LordAmit/Brightness |
Licenses: | GPL |
Conflicts: | brightness-controller |
Provides: | brightness-controller |
Submitter: | dracorp |
Maintainer: | yochananmarqos |
Last Packager: | yochananmarqos |
Votes: | 12 |
Popularity: | 0.23 |
First Submitted: | 2018-02-28 16:40 (UTC) |
Last Updated: | 2022-10-23 16:03 (UTC) |
Dependencies (9)
- ddcutil(ddcutil-git, ddcutil-dev-git)
- python-pyqt5(python-pyqt5-webkit, python-pyqt5-sip4)
- python-qtpy(python-qtpy-git)
- xorg-xrandr(xorg-xrandr-git)
- git(git-vfs, git-run-command-patch-git, git-git, git-fc)(make)
- python-build(make)
- python-installer(python-installer-git)(make)
- python-poetry-core(python-poetry-core-git)(make)
- python-wheel(make)
Required by (0)
Sources (4)
Latest Comments
yochananmarqos commented on 2022-10-03 15:56 (UTC) (edited on 2022-10-03 15:56 (UTC) by yochananmarqos)
@peter.kehl: Your Python path seems to be in your home directory. Please refer to the Manjaro forum for support.
Please edit your comment to use proper formatting using Markdown:
peter.kehl commented on 2022-10-03 15:23 (UTC)
The current package is failing to build. My Manjaro is up-to-date but old (over 3+years) - I know that it "shouldn't matter", but I did see (GUI) differences between my Manjaro and a newer installation. Anyway, the error:
Preparing. Synchronizing package databases. Refreshing pritunl.db. Checking brightness-controller-git dependencies. Warning: glide: local (0.13.3-3) is newer than community (0.5.9-2) Warning: gnome-wallpapers: local (20201023-1) is newer than community (20201020-1) Resolving dependencies. Checking inter-conflicts. Warning: dependency cycle detected: Warning: python-poetry-plugin-export will be installed before its python-poetry dependency Download of python-crashtest (0.4.0-1) started Download of python-crashtest (0.4.0-1) finished Download of python-secretstorage (3.3.3-1) started Download of python-secretstorage (3.3.3-1) finished Download of python-tomlkit (0.11.4-1) started Download of python-pkginfo (1.8.3-1) started Download of python-tomlkit (0.11.4-1) finished Download of python-pkginfo (1.8.3-1) finished Download of python-keyring (23.9.0-1) started Download of python-cachy (0.3.0-7) started Download of python-keyring (23.9.0-1) finished Download of python-cachy (0.3.0-7) finished Download of python-lark-parser (1.1.2-1) started Download of python-cleo (1.0.0a5-2) started Download of python-lark-parser (1.1.2-1) finished Download of python-cleo (1.0.0a5-2) finished Download of python-pylev (1.4.0-4) started Download of python-pylev (1.4.0-4) finished Download of python-poetry-core (1.1.0-1) started Download of python-poetry-core (1.1.0-1) finished Download of python-entrypoints (0.4-2) started Download of python-entrypoints (0.4-2) finished Download of python-virtualenv (20.13.1-1) started Download of python-filelock (3.8.0-1) started Download of python-filelock (3.8.0-1) finished Download of python-poetry (1.2.0-5) started Download of python-poetry (1.2.0-5) finished Download of python-shellingham (1.5.0-1) started Download of python-shellingham (1.5.0-1) finished Download of python-poetry-plugin-export (1.0.6-2) started Download of python-poetry-plugin-export (1.0.6-2) finished Download of python-virtualenv (20.13.1-1) finished Download of python-requests-toolbelt (0.9.1-7) started Download of python-requests-toolbelt (0.9.1-7) finished Checking keyring. Checking integrity. Loading packages files. Checking file conflicts. Checking available disk space. Installing python-crashtest (0.4.0-1). Installing python-secretstorage (3.3.3-1). Installing python-pkginfo (1.8.3-1). Installing python-entrypoints (0.4-2). Installing python-keyring (23.9.0-1). Installing python-cachy (0.3.0-7). Installing python-pylev (1.4.0-4). Installing python-cleo (1.0.0a5-2). Installing python-lark-parser (1.1.2-1). Installing python-tomlkit (0.11.4-1). Installing python-poetry-core (1.1.0-1). Installing python-requests-toolbelt (0.9.1-7). Installing python-shellingham (1.5.0-1). Installing python-filelock (3.8.0-1). Installing python-virtualenv (20.13.1-1). Installing python-poetry (1.2.0-5). Installing python-poetry-plugin-export (1.0.6-2). Running post-transaction hooks. Arming ConditionNeedsUpdate. Cloning brightness-controller-git build files. Generating brightness-controller-git information.
Building brightness-controller-git. ==> Making package: brightness-controller-git 2.4.r5.g7c4a27e-3 (Sun 02 Oct 2022 04:35:23 PM) ==> Checking runtime dependencies. ==> Checking buildtime dependencies. ==> Retrieving sources. -> Cloning brightness-controller git repo. Cloning into bare repository '/var/tmp/pamac-build-pkehl/brightness-controller-git/brightness-controller'. -> Downloading brightness-controller.1.gz. % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 647 100 647 0 0 962 0 --:--:-- --:--:-- --:--:-- 962 -> Found brightness-controller.desktop -> Found brightness-reset.sh ==> Validating source files with sha256sums. brightness-controller . Skipped brightness-controller.1.gz . Passed brightness-controller.desktop . Passed brightness-reset.sh . Passed ==> Removing existing $srcdir/ directory. ==> Extracting sources. -> Creating working copy of brightness-controller git repo. Cloning into 'brightness-controller'. done. -> Extracting brightness-controller.1.gz with gzip ==> Starting prepare(). ==> Starting pkgver(). ==> Starting build(). * Getting dependencies for wheel. * Building wheel. Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 351, in main() File "/usr/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 333, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 249, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/home/pkehl/.local/lib/python3.10/site-packages/poetry/core/masonry/api.py", line 66, in build_wheel poetry = Factory().create_poetry(Path(".").resolve(), with_dev=False) File "/home/pkehl/.local/lib/python3.10/site-packages/poetry/core/factory.py", line 43, in create_poetry raise RuntimeError("The Poetry configuration is invalid:\n" + message) RuntimeError: The Poetry configuration is invalid: - Additional properties are not allowed ('group' was unexpected)
ERROR Backend subprocess exited when trying to invoke build_wheel ==> ERROR: A failure occurred in build(). Aborting.