Backlight - ArchWiki
Backlight - ArchWiki
Backlight - ArchWiki
Screen brightness might be tricky to control. On some machines physical hardware switches are missing and software solutions may not work well. However, it is generally possible to find a
functional method for a given hardware. This article aims to summarize all possible ways to adjust the backlight.
There are many ways to control brightness of a monitor, laptop or integrated panel (such as the iMac). According to these (https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+
bug/397617) discussions (https://lore.kernel.org/patchwork/patch/528936/#708706) and this wiki page (https://wiki.ubuntu.com/Kernel/Debugging/Backlight) the control method can be
divided into these categories:
▪ brightness is controlled by vendor-specified hotkey and there is no interface for the OS to adjust the brightness.
▪ brightness is controlled by either the ACPI, graphic or platform driver. In this case, backlight control is exposed to the user through
/sys/class/backlight which can be used by user-space backlight utilities.
▪ brightness is controlled by writing into a graphic card register through setpci.
Note: Since OLED screens have no backlight, brightness cannot be controlled by changing backlight power on laptops equipped with an OLED screen. In this case, perceived screen brightness can be adjusted with a PWM
control (not implemented in the Linux kernel) or via software color correction.
1 Hardware interfaces
1.1 ACPI
The brightness of the screen backlight is adjusted by setting the power level of the backlight LEDs or cathodes. The power level can often be controlled using the ACPI kernel module for video. An
interface to this module is provided via a sysfs(5) (https://man.archlinux.org/man/sysfs.5) directory at /sys/class/backlight/ .
$ ls /sys/class/backlight/
acpi_video0
In this case, the backlight is managed by an ATI graphics card. In the case of an Intel card, the directory is called intel_backlight . In the following examples, acpi_video0 is used. If
you use an Intel card, simply replace acpi_video0 with intel_backlight in the examples.
$ ls /sys/class/backlight/acpi_video0/
The maximum brightness can be displayed by reading from max_brightness , which is often 15.
$ cat /sys/class/backlight/acpi_video0/max_brightness
15
The brightness can be set by writing a number to brightness . Attempting to set a brightness greater than the maximum results in an error.
By default, only root can change the brightness by this method. To allow users in the video group to change the brightness, a udev rule such as the following can be used (Logging
out/Rebooting may be necessary to changes take effects):
/etc/udev/rules.d/backlight.rules
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. This results in, for instance, inaccurate brightness notifications. This includes some laptops with
dual graphics (e.g., NVIDIA/AMD dedicated GPU with Intel/AMD integrated GPU). Additionally, ACPI sometimes needs to register its own acpi_video0 backlight even if one already exists
(such as intel_backlight ), which can be done by adding one of the following kernel parameters:
acpi_backlight=video
acpi_backlight=vendor
acpi_backlight=native
Tip:
▪ On Nvidia Optimus laptops, the kernel parameter nomodeset can interfere with the ability to adjust the backlight.
▪ On an Asus notebooks you might also need to load the asus-nb-wmi kernel module.
▪ Disabling legacy boot on Dell XPS13 breaks backlight support.
▪ Since Linux 6.1 the backlight subsystem was revamped (https://hansdegoede.livejournal.com/26427.html), if your backlight does not work after
an update first try to remove an existing acpi_backlight kernel parameter. On some Optimus laptops, you can try booting with
acpi_backlight=nvidia_wmi_ec .
If the ACPI interface is available, the backlight level can be set at boot using a udev rule:
/etc/udev/rules.d/81-backlight.rules
Note: The systemd-backlight service restores the previous backlight brightness level at boot. To prevent conflicts for the above rules, see #Save and restore functionality.
Tip: To set the backlight depending on power state, see Power management#Using a script and an udev rule and use your favourite backlight utility in the script.
1.2 setpci
In some cases (e.g. Intel Mobile 945GME [1] (https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617)), it is possible to set the register of the graphic card to adjust
the backlight. It means you adjust the backlight by manipulating the hardware directly, which can be risky and generally is not a good idea. Not all of the graphic cards support this method.
When using this method, you need to use lspci first to find out where your graphic card is.
Feature: 10 (Brightness)
# ddcutil getvcp 10
VCP code 0x10 (Brightness ): current value = 60, max value = 100
# ddcutil setvcp 10 70
Alternatively, one may use ddcci-driver-linux-dkms (https://aur.archlinux.org/packages/ddcci-driver-linux-dkms/)AUR to expose external monitors in sysfs.
Then, after loading the ddcci kernel module, one can use any backlight utility.
Note:
▪ Using ddcci and i2c-dev simultaneously may result in resource conflicts such as a Device or resource busy error.
▪ Users of NVIDIA's proprietary drivers may need to add Option "RegistryDwords" "RMUseSwI2c=0x01; RMI2cSpeed=100" to the Device section in
the Xorg configuration or the NVreg_RegistryDwords=RMUseSwI2c=0x01;RMI2cSpeed=100 kernel module parameter for the nvidia module.
See [2] (https://forums.developer.nvidia.com/t/gddccontrol-issues-with-nvidia-drivers-i2c-monitor-display-ddc-dp-hdmi-failing/30427/3
3) and [3] (https://forums.developer.nvidia.com/t/gddccontrol-issues-with-nvidia-drivers-i2c-monitor-display-ddc-dp-hdmi-failing/30427
/61).
▪ ddcutil will fail to set some VCP features if there is a feature enabled on the monitor which already automatically adjusts them (e.g. Dynamic
Contrast Ratio or BenQ's Eye Care technology).
▪ To facilitate binding screen brightness control to a keyboard shortcut, it may be convenient to enable non-superuser access to the relevant I2C devices.
This can be achieved by adding a group i2c and configuring udev to set this group as the owner of the I2C devices. See [4] (https://raspberrypi.st
ackexchange.com/a/4472).
▪ If ddcutil (https://archlinux.org/packages/?name=ddcutil) is installed, it provides the /usr/share/ddcutil/data/90-nvidia-i2c.conf file,
which can be copied to /etc/X11/xorg.conf.d/ instead of manually editing Xorg configuration files. It also provides
/usr/share/ddcutil/data/60-ddcutil-i2c.rules and /usr/share/ddcutil/data/60-ddcutil-usb.rules for udev rules.
The backlight should switch on again on mouse movement or keyboard input. Alternately, xset s could be used for a similar effect.
If the previous commands do not work, there is a chance that vbetool may work. Note, however, that in this case the backlight must be manually activated again. The command is as follows:
$ vbetool dpms on
For example, this can be put to use when closing the notebook lid using acpid.
Note: Some laptops have multiple video cards (e.g. Optimus) and the backlight restoration fails. Try masking an instance of the service (e.g. systemd-backlight@backlight:acpi_video1 for
acpi_video1 ).
4 Backlight utilities
Note: The utilities in the following table can be used to control screen brightness. All of them are compatible with Wayland and do not require X. Some (like brightnessctl (https://archlinux.org/packag
es/?name=brightnessctl) or light (https://aur.archlinux.org/packages/light/)AUR) add udev rules to allow members of the video (or input ) group to modify brightness.
Controls Reacts to
Package name keyboard ambient Language License Notes
backlights brightness
acpilight (https://archlinux.org/p GPL-3.0-or-
Yes No Python3 "xbacklight" executable provided
ackages/?name=acpilight) later
backlight_control (https://aur.arc
hlinux.org/packages/backlight_cont No No C MIT Extremely small and simple. Supports relative adjustments.
rol/)AUR
blight (https://aur.archlinux.org/ Uses logind interface. Restricted to local users, but does not require
Yes No Python3 ISC
packages/blight/)AUR suid or video group membership.
brightd (https://aur.archlinux.org
No No C GPL-2.0 Dims the screen when there is no user input for some time.
/packages/brightd/)AUR
brightnessctl (https://archlinux.o
Yes No C MIT -
rg/packages/?name=brightnessctl)
brillo (https://aur.archlinux.org/
Yes No C GPL-3.0-only Supports smooth and relative adjustments.
packages/brillo/)AUR
Manages screen temperature (Xorg only) and smoothly dims
clight (https://aur.archlinux.org/ GPL-3.0-or- brightness after a timeout. Supports ambient light sensors [5] (https://
Yes Yes C
packages/clight/)AUR later github.com/FedeDP/Clightd/wiki/Sensors). Can turn webcam into
an ambient light sensor.
enlighten-git (https://aur.archlin GPL-3.0-or-
Yes No C -
ux.org/packages/enlighten-git/)AUR later
illum-git (https://aur.archlinux.o
No No C AGPL-3.0 Reacts to key presses.
rg/packages/illum-git/)AUR
light (https://aur.archlinux.org/p
Yes No C GPL-3.0-only Dependency free. Does not rely on X server.
ackages/light/)AUR
lux (https://aur.archlinux.org/pac
No No Shell MIT -
kages/lux/)AUR
macbook-lighter (https://aur.archl
Macbook screen/keyboard backlight CLI and auto-adjust on ambient
inux.org/packages/macbook-lighter Yes Yes Bash GPL
light.
/)AUR
wlr-brightness-git (https://aur.ar
Also supports newer OLED displays that need gamma adjustment. Uses
chlinux.org/packages/wlr-brightnes No No C MIT
wlroots.
s-git/)AUR
Automatic brightness adjustment based on screen contents and
wluma (https://aur.archlinux.org/p
Yes Yes Rust ISC ambient light. Can use webcam or time to simulate ambient light
ackages/wluma/)AUR
sensor. Supports keyboards and external monitors. Uses wlroots.
ybacklight (https://aur.archlinux.
No No Perl GPL-2.0 Small Perl script similar to xbacklight but using sysfs drivers.
org/packages/ybacklight/)AUR
xbacklight-notify (https://aur.arc
Simple notification daemon for X11 (reads the RandR backlight
hlinux.org/packages/xbacklight-not No No C MIT
property)
ify/)AUR
acpi-backlight-notify (https://au
Simple notification daemon for the ACPI interface (reads
r.archlinux.org/packages/acpi-back No No C MIT
/sys/class/backlight/ )
light-notify/)AUR
Tip: Commands involving these utilities can be bound to the XF86MonBrightnessUp and XF86MonBrightnessDown keyboard keys as described in Keyboard shortcuts#Xorg.
4.1 xbacklight
Note:
▪ xbacklight only works with Intel. Other drivers did not add support for the RandR backlight property.
▪ xbacklight currently does not work with the modesetting driver [6] (https://gitlab.freedesktop.org/xorg/xserver/issues/47).
$ xbacklight -set 50
Increments can be used instead of absolute values, for example to increase or decrease brightness by 10%:
$ xbacklight -inc 10
$ xbacklight -dec 10
If you get the "No outputs have backlight property" error, it is because xrandr/xbacklight does not choose the right directory in /sys/class/backlight . You can specify the directory by
setting the Backlight option of the device section in /etc/X11/xorg.conf.d/20-video.conf . For instance, if the name of the directory is intel_backlight and using the
Intel driver, the device section may be configured as follows:
/etc/X11/xorg.conf.d/20-intel.conf
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection
Note: Using this with an iGPU+dGPU setup can cause unpredictable screen update lag and/or flickering in user interface items inside apps that are offloaded to the dGPU. Only use this if all else fails.
If you have enabled Intel Fastboot you might also get the No outputs have backlight property error. In this case, trying the above method may cause Xorg to crash on start up. You
should disable it to fix the issue. It is known (https://bugs.freedesktop.org/show_bug.cgi?id=108225) to cause issues with brightness control.
4.2 light
Note: The GitHub page for light (https://github.com/haikarainen/light)[dead link 2024-03-03 ⓘ] states: This project is considered orphaned since the 8th of March, 2023. Use is heavily discouraged until such a time that it
is adopted by another developer.
Install light (https://aur.archlinux.org/packages/light/)AUR and add your user to the video user group.
$ light -A 5
Decrease backlight brightness by 5 percent:
$ light -U 5
$ light -S 100
$ gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.freedesktop.DBus.Properties.Set org.gnome.SettingsDaemon.Power.Screen Bri
ghtness "<int32 50>"
Steps in brightness for keyboard control can be implemented with this method as well.
5 Color correction
Color correction does not change the backlight power, it just modifies the video lookup table: this means that your battery life will be unaffected by the change. Nevertheless, it could be useful when
no backlight control is available (desktop PCs or laptops with OLED screens).
▪ Clight — User daemon utility that aims to fully manage your display. It can manage the screen temperature depending on the current time of the day,
just like redshift does. It tries to use geoclue (https://archlinux.org/packages/?name=geoclue) to retrieve the user position if neither latitude or
longitude are set in the configuration file. It also supports fixed times for sunrise and sunset.
▪ Monica — Monitor calibration tool. It works as frontend to xgamma to alter the gamma correction.
▪ Redshift — Color temperature adjustment tool. It adjusts the color temperature of your screen according to your surroundings. This may help your eyes
hurt less if you are working in front of the screen at night. This program is inspired by f.lux.
▪ xcalib — Lightweight monitor calibration loader which can load an ICC monitor profile to be shared across desktop applications.
5.1 Wayland
Redshift does not support Wayland (without a patch or fork like redshift-wayland-git (https://aur.archlinux.org/packages/redshift-wayland-git/)AUR). But it is
possible to apply the desired temperature in tty before starting a compositor. For example:
To adjust perceived brightness above its maximum level (the same caveats mentioned above for Nvidia apply):
This should roughly double luma in the image. It will sacrifice color quality for brightness, nevertheless it is particularly suited for situations where the ambient light is very bright (e.g. sunlight).
This can also be used to reduce perceived brightness in a dark room by specifying some value less than 1 (e.g. 0.5), this is useful when no backlight control is available (e.g. desktop PC).
The output name of the connected device may be determined by calling xrandr :
To automatically call xrandr when a backlight file changes, oled_shmoled (https://aur.archlinux.org/packages/oled_shmoled/)AUR can be used like so:
$ oled_shmoled output_name
6 Troubleshooting
However, the frequency of the switching, so-called PWM (pulse-width modulation) frequency, may not be high enough for the eye to perceive it as a single brightness and instead see flickering. This
causes some people to have symptoms such as headaches and eyestrain.
If you have an Intel i915 GPU, then it may be possible to adjust PWM frequency to eliminate flicker.
Period of PWM (inverse to frequency) is stored in 2 higher bytes of 0xC8254 register (if you are using the Intel GM45 chipset use address 0x61254 instead). To manipulate registers values,
install the intel-gpu-tools (https://archlinux.org/packages/?name=intel-gpu-tools) package.
0xC8254 : 0x12281228
Then to double PWM frequency divide 2 higher bytes (4 higher hex digits) by 2 and write back resulting value, keeping lower bytes unchanged:
To set new frequency automatically, consider writing an udev rule or install intelpwm-udev (https://aur.archlinux.org/packages/intelpwm-udev/)AUR.
This problem may be solved by adding i915.invert_brightness=1 to the list of kernel parameters.
By default the i915 driver tries to use PWM to control backlight brightness, which might not work.
To set the backlight through writes to DPCD registers using the AUX channel set i915.enable_dpcd_backlight=1 as a kernel parameter.
Note: The parameter changed from bool to int in linux (https://archlinux.org/packages/?name=linux) 5.4.
On some systems, the brightness hotkeys on your keyboard correctly modify the values of the acpi interface in /sys/class/backlight/acpi_video0/actual_brightness but the
brightness of the screen is not changed. Brightness applets from desktop environments may also show changes to no effect.
If you have tested the recommended kernel parameters and only xbacklight works, then you may be facing an incompatibility between your BIOS and kernel driver.
In this case the only solution is to wait for a fix either from the BIOS or GPU driver manufacturer.
A workaround is to use the inotify kernel api to trigger xbacklight each time the value of /sys/class/backlight/acpi_video0/actual_brightness changes.
First install inotify-tools (https://archlinux.org/packages/?name=inotify-tools). Then create a script around inotify that will be launched upon each boot or through
autostart.
/usr/local/bin/xbacklightmon
#!/bin/sh
path=/sys/class/backlight/acpi_video0
luminance() {
read -r level < "$path"/actual_brightness
factor=$(printf "$max" | awk '{print 100/$1}')
printf "$level $factor" | awk '{print int($1*$2)}'
}
i915 0000:00:02.0: [drm] *ERROR* [CONNECTOR:114:DSI-1] Failed to get the SoC PWM chip
/etc/mkinitcpio.conf
...
MODULES=(i915 pwm-lpss-platform)
...
In some installations of Xfce, the "Handle display brightness keys" setting may be turned off by default.
To activate the brightness keys again, open the Xfce Power Manager dialog (https://docs.xfce.org/xfce/xfce4-power-manager/preferences) and toggle on "Handle display brightness keys":
$ xfce4-power-manager -c
Depending on the video card installed, sometimes xbacklight from xorg-xbacklight (https://archlinux.org/packages/?name=xorg-xbacklight) returns the message
"No outputs have backlight property". Installing acpilight (https://archlinux.org/packages/?name=acpilight) provides an alternative xbacklight that may work as
expected.
6.9 Backlight is always at full brightness after a reboot with amdgpu driver
Due to a bug (https://bugzilla.kernel.org/show_bug.cgi?id=203905) introduced recently in the amdgpu driver, the backlight's actual_brightness value is reported as a 16-bit integer,
which is outside the 8-bit range specified in max_brightness . This causes the systemd-backlight service to attempt to restore, at boot time, a value that is too large and ends being
truncated to maximum brightness (255).
While the bug is not addressed, one possible workaround is to modify the stored brightness to within the correct range before it is restored. This can be accomplished with a script and a service unit:
fix-brightness.sh
#!/bin/bash
fix-brightness.service
[Unit]
Description=Convert 16-bit brightness values to 8-bit before systemd-backlight applies it
Before=systemd-backlight@backlight:amdgpu_bl0.service
[Service]
Type=oneshot
ExecStart=<path to the script above>
[Install]
WantedBy=multi-user.target
On certain systems, the backlight level reported by the driver is in the correct range [0, 255], but systemd still fails to restore the correct value. This is probably due to a race in the kernel (https://git
lab.freedesktop.org/drm/amd/-/issues/1337). In this case, truncating the brightness level will not help since it is already in the correct range. Instead, saving the brightness level to systemd before
shutting down could work as a workaround. This can be accomplished by the following script and service unit:
fix-brightness.sh
#!/bin/sh
fix-brightness.service
[Unit]
Description=Save brightness value from AMDGPU
DefaultDependencies=no
After=final.target
[Service]
Type=oneshot
ExecStart=<path to the script above>
[Install]
WantedBy=final.target
6.10 Allow <5% brightness to persist on reboot (disable backlight clamp)
/etc/udev/rules.d/99-backlight_clamp.rules