Backlight

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 discussions and this wiki page 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.

Hardware interfaces

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) directory at /sys/class/backlight/.

The name of the directory depends on the graphics card model.

$ 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.

The directory contains the following files and subdirectories:

$ ls /sys/class/backlight/acpi_video0/
actual_brightness  brightness         max_brightness     subsystem/    uevent             
bl_power           device/            power/             type

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.

# echo 5 > /sys/class/backlight/acpi_video0/brightness

By default, only can change the brightness by this method. To allow users in the group to change the brightness, a udev rule such as the following can be used:

Kernel command-line options

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/Radeon 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

If you find that changing the acpi_video0 backlight does not actually change the brightness, you may need to use acpi_backlight=none.

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.

Udev rule

If the ACPI interface is available, the backlight level can be set at boot using a udev rule:

setpci

In some cases (e.g. Intel Mobile 945GME ), 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 first to find out where your graphic card is.

# setpci -s 00:02.0 F4.B=0

External monitors

DDC/CI (Display Data Channel Command Interface) can be used to communicate with external monitors implementing MCCS (Monitor Control Command Set) over I2C. DDC can control brightness, contrast, inputs, etc on supported monitors. Settings available via the OSD (On-Screen Display) panel can usually also be managed via DDC. The kernel module may need to be loaded if the devices do not exist.

can be used to query and set brightness settings:
# ddcutil getvcp 10
VCP code 0x10 (Brightness                    ): current value =    60, max value =   100
# ddcutil setvcp 10 70

Alternatively, one may use ddcci-driver-linux-dkmsAUR to expose external monitors in sysfs. Then, after loading the kernel module, one can use any backlight utility.

Switch off the backlight

Switching off the backlight (for example when one locks a notebook) can be useful to conserve battery energy. Ideally the following command should work for any Xorg graphical session:

$ xset dpms force off

The backlight should switch on again on mouse movement or keyboard input. Alternately, 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 off

To activate the backlight again:

$ vbetool dpms on

For example, this can be put to use when closing the notebook lid using acpid.

Save and restore functionality

The systemd package includes the service , which is enabled by default and "static". It saves the backlight brightness level at shutdown and restores it at boot. The service uses the ACPI method described in #ACPI, generating services for each folder found in /sys/class/backlight/. For example, if there is a folder named acpi_video0, it generates a service called . When using other methods of setting the backlight at boot, it is recommended to stop systemd-backlight from restoring the backlight by setting the kernel parameters parameter . See for details.

Additionally, the brilloAUR and utilities support save and restore functionality. These two may be more useful if one wishes to restore the screen brightness on a per-user basis, however no systemd units are provided to accomplish this.

Backlight utilities

Package name Controls keyboard backlights Reacts to ambient brightness Language License Notes
No Python3 GPL-3.0-or-later "xbacklight" executable provided
No No C MIT Extremely small and simple. Supports relative adjustments.
No Python3 ISC Uses logind interface. Restricted to local users, but does not require suid or video group membership.
No No C GPL-2.0 Dims the screen when there is no user input for some time.
No C MIT -
brilloAUR No C GPL-3.0-only Supports smooth and relative adjustments.
clightAUR C GPL-3.0-or-later Manages screen temperature (Xorg only) and smoothly dims brightness after a timeout. Supports ambient light sensors . Can turn webcam into an ambient light sensor.
No C GPL-3.0-or-later -
No No C AGPL-3.0 Reacts to key presses.
No C GPL-3.0-only -
No No Shell MIT -
Bash,Perl GPL Macbook screen/keyboard backlight CLI and auto-adjust on ambient light.
wlr-brightness-gitAUR No No C MIT Also supports newer OLED displays that need gamma adjustment. Uses wlroots.
Rust ISC Automatic brightness adjustment based on screen contents and ambient light. Can use webcam or time to simulate ambient light sensor. Supports keyboards and external monitors. Uses wlroots.
No No Perl GPL-2.0 Small Perl script similar to xbacklight but using sysfs drivers.
No No C MIT Simple notifification daemon

xbacklight

Brightness can be set using the xorg-xbacklight package.

To set brightness to 50% of maximum:

$ 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 option of the device section in . For instance, if the name of the directory is intel_backlight and using the Intel driver, the device section may be configured as follows:

See and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=651741 for details.

If you have enabled Intel Fastboot you might also get the 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 to cause issues with brightness control.

light

Install and add your user to the video group.

To list available devices:

$ light -L

Increase backlight brightness by 5 percent:

$ light -As "/sys/class/backlight/acpi_video0" 5

Using DBus with GNOME

Brightness can also be adjusted as the GNOME controls do. Changes are reflected in the GNOME UI using this method.

$ 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 Brightness "<int32 50>"

Steps in brightness for keyboard control can be implemented with this method as well.

$ gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.StepUp
$ gdbus call --session --dest org.gnome.SettingsDaemon.Power --object-path /org/gnome/SettingsDaemon/Power --method org.gnome.SettingsDaemon.Power.Screen.StepDown

Using DBus with KDE

See https://userbase.kde.org/KDE_Connect/Tutorials/Useful_commands#Brightness_settings.

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 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.
https://github.com/FedeDP/Clight || clightAUR

Wayland

Redshift does not support Wayland (without a patch or fork like ). But it is possible to apply the desired temperature in tty before starting a compositor. For example:

$ redshift -m drm -PO 3000

Otherwise some compositors can apply color correction during runtime:

Xorg: adjust perceived brightness with xrandr

xrandr may be used to adjust the perceived brightness.

To adjust perceived brightness above its maximum level (the same caveats mentioned above for Nvidia apply):

$ xrandr --output output_name --brightness 2

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 | grep -w connected | cut -f '1' -d ' '

Users may find it convenient to implement this as an alias:

$ alias b='echo -e "enter brightness:\n"; read val; xrandr  --output output name --brightness "${val}"'

To automatically call xrandr when a backlight file changes, can be used like so:

$ oled_shmoled output_name

NVIDIA settings

Users of NVIDIA's proprietary drivers can change display brightness via the nvidia-settings utility under "X Server Color Correction." However, note that this has absolutely nothing to do with backlight (intensity), it merely adjusts the color output. (Reducing brightness this way is a power-inefficient last resort when all other options fail; increasing brightness spoils your color output completely, in a way similar to overexposed photos.)

Troubleshooting

Backlight PWM modulation frequency (Intel i915 only)

Laptops with LED backlight are known to have screen flicker sometimes. This is because the most efficient way of controlling LED backlight brightness is by turning the LED's on and off very quickly varying the amount of time they are on.

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 instead). To manipulate registers values install from the official repositories.

To increase the frequency, period must be reduced. For example:

Then to double PWM frequency divide 2 higher bytes (4 higher hex digits) by 2 and write back resulting value, keeping lower bytes unchanged:

# intel_reg write 0xC8254 0x09141228

You can use online calculator to calculate desired value https://devbraindom.blogspot.com/2013/03/eliminate-led-screen-flicker-with-intel.html

To set new frequency automatically, consider writing an udev rule or install .

Inverted Brightness (Intel i915 only)

Symptoms:

  • after installing systemd-backlight.service turns off the backlight during boot
    • possible solution: mask systemd-backlight.service
  • switching from X to another VT turns the backlight off
  • the brightness keys are inverted (i.e. turning up the brightness makes the screen darker)

This problem may be solved by adding i915.invert_brightness=1 to the list of kernel parameters.

Unable to control eDP Panel brightness (Intel i915 only)

Embedded Display Port (eDP) v1.2 introduced a new display panel control protocol for backlight and other controls that works through the AUX channel

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 as a kernel parameter.

sysfs modified but no brightness change

On some systems, the brightness hotkeys on your keyboard correctly modify the values of the acpi interface in 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 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 each time the value of changes.

First install . Then create a script around inotify that will be launched upon each boot or through autostart.

Backlight not working in MATE

Make sure the mate-power-manager package is installed.

Backlight keys not working in Xfce

In xfce4, the Xfce4 Power Manager handles the brightness keys.

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 and toggle on "Handle display brightness keys":

$ xfce4-power-manager -c

xbacklight returns : No outputs have backlight property

Depending on the video card installed, sometimes xbacklight from xorg-xbacklight returns the message "No outputs have backlight property". Installing provides an alternative xbacklight that may work as expected.

Backlight is always at full brightness after a reboot with amdgpu driver

Due to a bug introduced recently in the amdgpu driver, the backlight's 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:

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. 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:

gollark: Look, we all know the "real" one can't ever happen.
gollark: `macron`
gollark: Please describe the rooster to me.
gollark: Yes, because it's part of a true document.
gollark: Sadly, I ran out of GPT-3 trial credits.
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.