Difference between revisions of "Backlight"

From ArchWiki
Jump to navigation Jump to search
(Add note about blacklisting the ideapad_laptop module to fix brightness control.)
(Backlight utilities)
 
(275 intermediate revisions by 89 users not shown)
Line 1: Line 1:
 
[[Category:Laptops]]
 
[[Category:Laptops]]
 
[[Category:Power management]]
 
[[Category:Power management]]
Screen brightness can often be tricky to control. On many machines, physical hardware switches are missing and software solutions may or may not work well. Make sure to find a working method for your hardware! Screens that are too bright can cause eye strain.
+
[[ru:Backlight]]
 +
[[ja:バックライト]]
 +
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 adjust the screen backlight of a monitor, laptop or integrated panel (such as the iMac) using software, but depending on hardware and model, sometimes only some options are available. This article aims to summarize all possible ways to adjust the backlight.
+
== Overview ==
  
==Overview==
+
There are many ways to control brightness of a monitor, laptop or integrated panel (such as the iMac). According to this [https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617 discussion] and this [https://wiki.ubuntu.com/Kernel/Debugging/Backlight wiki page] the control method can be divided into these categories:
There are many ways to control brightness. According to this discussion[https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617] and this wiki page [https://wiki.ubuntu.com/Kernel/Debugging/Backlight], the control method could be divided into these categories:
 
* brightness is controlled by vendor specified hotkey. And there is no interface for OS to adjust brightness.
 
* brightness is controlled by OS:
 
** brightness could be controlled by ACPI
 
** brightness could be controlled by graphic driver.
 
All methods expose themselves to the user by /sys/class/brightness. And xrandr/xbacklight could use this folder and choose one method to control brightness. But it is still not very clear which one xbacklight prefers by default.
 
''See FS#27677 for xbacklight, if you get "No outputs have backlight property."'' There is a temporary fix if xrandr/xbacklight does not choose the right directory in /sys/class/brightness: You can specify the one you want in xorg.conf by setting the "Backlight" option of the Device section to the name of that directory (see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=651741 at the bottom of the page for details).
 
* brightness is controlled by HW register throught setpci
 
  
==ACPI==
+
* brightness is controlled by vendor-specified hotkey and there is no interface for the OS to adjust the brightness.
It is often possible to adjust the backlight by ACPI. This controls the actual LEDs or cathodes of the screen. When this ACPI option is available, the illumination is controllable using a GUI slider in the Display/Screen system settings or by simple commands on the CLI.
+
* brightness is controlled by either the ACPI or the graphic driver.
 +
* brightness is controlled by HW register through setpci.
  
Different cards might manage this differently. Check {{ic|/sys/class/backlight}} to find out:
+
All methods are exposed to the user through {{ic|/sys/class/backlight}} and xrandr/xbacklight can choose one method to control brightness. It is still not very clear which one xbacklight prefers by default.
{{hc|# ls /sys/class/backlight/|
+
 
intel_backlight
+
== 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 directory at {{ic|/sys/class/backlight/}}.
 +
 
 +
The name of the folder depends on the graphics card model.
 +
 
 +
{{hc|$ ls /sys/class/backlight/|
 +
acpi_video0
 
}}
 
}}
  
So this particular backlight is managed by an Intel card. It is called {{ic|acpi_video0}} on an ATI card. In the following example, acpi_video0 is used.
+
In this case, the backlight is managed by an ATI graphics card. In the case of an Intel card it is called {{ic|intel_backlight}}. In the following example, {{ic|acpi_video0}} is used.
  
 
The directory contains the following files and folders:
 
The directory contains the following files and folders:
  
actual_brightness  brightness        max_brightness    subsystem/    uevent             
+
{{hc|$ ls /sys/class/backlight/acpi_video0/|
bl_power          device/            power/            type
+
actual_brightness  brightness        max_brightness    subsystem/    uevent             
 +
bl_power          device/            power/            type
 +
}}
  
The maximum brightness (often 15) can be found by running {{ic|cat}}:
+
The maximum brightness can be found by reading from {{ic|max_brightness}}, which is often 15.
  
# cat /sys/class/backlight/acpi_video0/max_brightness
+
{{hc|$ cat /sys/class/backlight/acpi_video0/max_brightness|
15
+
15
 +
}}
  
Brightness can then be set (as root) with {{ic|echo}}. Obviously you cannot go any higher than your screen's maximum brightness. The values for maximum brightness and brightness in general vary wildly among cards.  
+
The brightness can be set by writing a number to {{ic|brightness}}. Attempting to set a brightness greater than the maximum results in an error.
  
 
  # echo 5 > /sys/class/backlight/acpi_video0/brightness
 
  # echo 5 > /sys/class/backlight/acpi_video0/brightness
  
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. This include some models with dual graphics (e.g. Nvidia-optimus/Radeon with intel (i915)) and some examples with this problem in notebooks such as Dell Studio, Dell XPS 14/15/17 and some Lenovo series, Kamal Mostafa kernel developer make [https://launchpad.net/~kamalmostafa/+archive/linux-kamal-mjgbacklight patches] for solved this problem included after 3.1 kernel version. You can try adding the following kernel parameters in your bootloader(grub, syslinux...) to adjust ACPI model:
+
By default, only {{ic|root}} can change the brightness by this method. To allow users in the {{ic|video}} group to change the brightness, a [[udev]] rule such as the following can be used:
  
acpi_osi=Linux acpi_backlight=vendor
+
{{hc|/etc/udev/rules.d/backlight.rules|<nowiki>
 +
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="acpi_video0", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
 +
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="acpi_video0", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"
 +
</nowiki>}}
  
or
+
=== Kernel command-line options ===
  
acpi_osi=Linux acpi_backlight=legacy
+
Sometimes, ACPI does not work well due to different motherboard implementations and ACPI quirks, resulting 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 {{ic|acpi_video0}} backlight even if one already exists (such as {{ic|intel_backlight}}), which can be done by adding one of the following [[kernel parameters]]:
''acpi_backlight=vendor will prefer vendor specific driver (e.g. thinkpad_acpi, sony_acpi, etc.) instead of the ACPI video.ko driver.''
 
  
For Lenovo IdeaPad laptops, you may also need to blacklist the {{ic|ideapad_laptop}} module by adding {{ic|blacklist ideapad_laptop}} to {{ic|/etc/modprobe.d/blacklist.conf}}, creating the file if needed. ([http://askubuntu.com/a/304762 Source])
+
acpi_backlight=video
 +
acpi_backlight=vendor
 +
acpi_backlight=native
  
{{Tip|Also, you can try:
+
If you find that changing the {{ic|acpi_video0}} backlight does not actually change the brightness, you may need to use {{ic|1=acpi_backlight=none}}.
<nowiki>
 
acpi_osi="!Windows 2012" acpi_backlight=vendor # On some new laptops with pre-installed Windows 8 and/or hybrid graphics
 
acpi_backlight=legacy
 
acpi_osi=Linux</nowiki>
 
and all combinations of these lines.
 
  
The first line works on asus G750 notebook (keys don't work, only from /sys/class/backlight/asus-nb-wmi/brightness. You need to also do
+
{{Tip|
modprobe asus-nb-wmi
+
* On Nvidia Optimus laptops, the kernel parameter {{ic|nomodeset}} can interfere with the ability to adjust the backlight.
 +
* On an Asus notebooks you might also need to load the {{ic|asus-nb-wmi}} [[kernel module]].
 +
* Disabling legacy boot on Dell XPS13 breaks backlight support.
 
}}
 
}}
{{Tip|If you have got intel_backlight and a manufacturer backlight (dell, toshiba, etc.) that stops working after suspend, try:
+
 
<nowiki>
+
=== Udev rule ===
acpi_backlight=vendor</nowiki>
+
 
and the following X11 quirk (/etc/X11/xorg.conf.d/80-backlight.conf):
+
If the ACPI interface is available, the backlight level can be set at boot using a [[udev]] rule:
<nowiki>
+
 
Section "Device"
+
{{hc|/etc/udev/rules.d/81-backlight.rules|<nowiki>
    Identifier  "Intel Graphics"
+
# Set backlight level to 8
    Driver      "intel"
+
SUBSYSTEM=="backlight", ACTION=="add", KERNEL=="acpi_video0", ATTR{brightness}="8"</nowiki>}}
    Option      "AccelMethod"     "sna"
+
 
    Option      "Backlight"      "intel_backlight" # use your backlight that works here
+
{{Note|The systemd-backlight service restores the previous backlight brightness level at boot. To prevent conflicts for the above rules, see [[#systemd-backlight service]]{{Broken section link}}.}}
     Driver      "intel"
+
 
    BusID      "PCI:0:2:0"
+
{{Tip|To set the backlight depending on power state, see [[Power management#Using a script and an udev rule]] and use your favourite [[#Backlight utilities|backlight utility]] in the script.}}
EndSection</nowiki>
+
 
 +
== 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 {{ic|xset s}} could be used.
 +
 
 +
The following example will toggle the screen saver timeout for a similar result (should be bound to a key):
 +
 
 +
{{hc|~/.local/bin/xlcd.sh|
 +
#!/usr/bin/dash
 +
read lcd < /tmp/lcd
 +
     if [ "$lcd" -eq "0" ]; then
 +
        xset s
 +
        echo 1 > /tmp/lcd
 +
        sleep 1
 +
        notify-send -t 2000 LCD\ ON
 +
    else
 +
        xset s 3
 +
        echo 0 > /tmp/lcd
 +
        notify-send -t 2000 LCD\ OFF
 +
    fi
 
}}
 
}}
  
==Switching off the backlight==
+
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
  
Switching off the backlight (for example when one locks the notebook) can be useful to conserve battery energy. Ideally the following command inside of a graphical session should work:
 
sleep 1 && xset dpms force off
 
The backlight should switch on again on mouse movement or keyboard input. If the previous command does not work, there is a chance that {{ic|vbetool}} works. 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:
 
To activate the backlight again:
vbetool dpms on
 
  
For example, this can be put to use when closing the notebook lid as outlined in the entry for [[Acpid#Laptop_Monitor_Power_Off|Acipd]].
+
$ vbetool dpms on
  
==Backlight utilities==
+
For example, this can be put to use when closing the notebook lid using [[Acpid]].
===xbacklight===
 
You can adjust the backlight through the xorg-server command {{ic|xbacklight}}.  The utility is provided by the {{Pkg|xorg-xbacklight}} package in [extra].
 
  
A useful demonstration was posted by [http://www.youtube.com/watch?v=_pi3iKMAJcY gotbletu on YouTube]. He suggests the following commands to adjust the backlight:
+
== Save/Restore functionality ==
  
* brighten up:
+
The [[systemd]] package includes the service {{ic|systemd-backlight@.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 {{ic|/sys/class/backlight/}}. For example, if there is a folder named {{ic|acpi_video0}}, it generates a service called {{ic|systemd-backlight@backlight:acpi_video0.service}}. 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 {{ic|1=systemd.restore_state=0}}. See {{man|8|systemd-backlight@.service}} for details.
xbacklight -inc 40
 
  
* dim down:
+
{{Note|Some laptops have multiple video cards (e.g. Optimus) and the backlight restoration fails. Try [[systemd#Using units|masking]] an instance of the service (e.g. {{ic|systemd-backlight@backlight:acpi_video1}} for {{ic|acpi_video1}}).}}
xbacklight -dec 40
 
  
===xcalib===
+
The {{AUR|relight}} package provides an alternative systemd-based method of saving and restoring screen brightness.
The package {{AUR|xcalib}} ([http://xcalib.sourceforge.net/ upstream url]) is available in the [[Arch User Repository|AUR]] and can be used to dim the screen. Again, the user gotbletu posted a demonstration on [http://www.youtube.com/watch?v=A9xsvntT6i4 Youtube]. This program can correct gamma, invert colors and reduce contrast, the latter of which we use in this case:
 
  
* dim down:
+
Additionally, the {{AUR|brillo}} and {{Pkg|light}} utilities support save/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.
xcalib -co 40 -a
 
  
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.
+
== Backlight utilities ==
 +
 
 +
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.
 +
 
 +
{| class="wikitable sortable"
 +
!| Name
 +
! Controls keyboard backlights
 +
! Reacts to ambient brightness
 +
! Language
 +
! License
 +
! Notes
 +
! Package
 +
! Homepage
 +
|-
 +
| acpilight
 +
| {{Yes}}
 +
| {{No}}
 +
| Python3
 +
| GPL-3.0-or-later
 +
| "xbacklight" compatible
 +
| {{Pkg|acpilight}}
 +
| https://gitlab.com/wavexx/acpilight
 +
|-
 +
| brightd
 +
| {{No}}
 +
| {{No}}
 +
| C
 +
| GPL-2.0
 +
| Dims the screen when there is no user input for some time.
 +
| {{AUR|brightd}}
 +
| http://www.pberndt.com/Programme/Linux/brightd
 +
|-
 +
| brillo
 +
| {{Yes}}
 +
| {{No}}
 +
| C
 +
| GPL-3.0-only
 +
| Supports smooth and relative adjustments.
 +
| {{AUR|brillo}}
 +
| https://gitlab.com/cameronnemo/brillo
 +
|-
 +
| brightnessctl
 +
| {{Yes}}
 +
| {{No}}
 +
| C
 +
| MIT
 +
| {{Y|Binary is setuid unless otherwise configured.}}
 +
| {{AUR|brightnessctl}}
 +
| https://github.com/Hummer12007/brightnessctl
 +
|-
 +
| Calise
 +
| {{No}}
 +
| {{Yes}}
 +
| Python2
 +
| GPL-3.0
 +
| -
 +
| {{AUR|calise}}
 +
| http://calise.sourceforge.net
 +
|-
 +
| Clight
 +
| {{Yes}}
 +
| {{Yes}}
 +
| C
 +
| GPL-3.0-or-later
 +
| Manages screen temperature and smoothly dims brightness after a timeout. Turns webcam into an ambient light sensor.
 +
| {{AUR|clight}}
 +
| https://github.com/FedeDP/Clight
 +
|-
 +
| macbook-lighter
 +
| {{Yes}}
 +
| {{Yes}}
 +
| Bash,Perl
 +
| GPL
 +
| Macbook screen/keyboard backlight CLI and auto-adjust on ambient light.
 +
| {{AUR|macbook-lighter}}
 +
| https://github.com/harttle/macbook-lighter
 +
|-
 +
| enlighten
 +
| {{No}}
 +
| {{No}}
 +
| C
 +
| GPL-3.0-or-later
 +
| -
 +
| {{AUR|enlighten-git}}
 +
| https://github.com/HalosGhost/enlighten
 +
|-
 +
| illum
 +
| {{No}}
 +
| {{No}}
 +
| C
 +
| AGPL-3.0
 +
| Reacts to key presses.
 +
| {{AUR|illum-git}}
 +
| https://github.com/jmesmon/illum
 +
|-
 +
| Light
 +
| {{Yes}}
 +
| {{No}}
 +
| C
 +
| GPL-3.0-only
 +
| {{Y|Binary is setuid unless otherwise configured.}}
 +
| {{Pkg|light}}
 +
| https://haikarainen.github.io/light
 +
|-
 +
| Lux
 +
| {{No}}
 +
| {{No}}
 +
| Shell
 +
| MIT
 +
| -
 +
| {{AUR|lux}}
 +
| https://github.com/Ventto/lux
 +
|}
  
===redshift===
+
=== xbacklight ===
The program [[redshift]] in the community repository uses {{ic|randr}} to adjust the screen brightness depending on the time of day and your geographic position. It can also do RGB gamma corrections and set color temperatures. As with {{ic|xcalib}}, this is very much a software solution and the look of the mouse cursor is unaffected. To execute a single quick adjustment of the brightness, try something like this:
 
  
redshift -o -l 0:0 -b 0.8 -t 6500:6500
+
Brightness can be set using the {{Pkg|xorg-xbacklight}} package.
  
{{Tip|If your longitude is west or your latitude is south, you should input it as negative.
+
{{Note|1=<nowiki></nowiki>
Example for Berkeley, CA:  
+
* xbacklight only works with [[Intel]]. [[Radeon]] does not support the RandR backlight property.
gtk-redshift -l 37.8717:-122.2728
+
* xbacklight currently does not work with the modesetting driver [https://gitlab.freedesktop.org/xorg/xserver/issues/47].
 
}}
 
}}
  
===relight===
+
To set brightness to 50% of maximum:
[http://xyne.archlinux.ca/projects/relight relight] is available in [http://xyne.archlinux.ca/repos Xyne's repos] and as package {{AUR|relight}} in the [[Arch User Repository|AUR]]. The package provides a service to automatically restore previous backlight settings during reboot along using the ACPI method explained above. The package also contains a dialog-based menu for selecting and configuring backlights for different screens.
+
 
 +
$ 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
 +
 
 +
Gamma can be set using either the {{Pkg|xorg-xrandr}} or {{Pkg|xorg-xgamma}} package. The following commands create the same effect:
 +
 
 +
$ xrandr --output LVDS1 --gamma 1.0:1.0:1.0
 +
$ xgamma -rgamma 1 -ggamma 1 -bgamma 1
 +
 
 +
{{Tip|These commands can be bound to keyboard keys as described in [[Keyboard shortcuts#Xorg]].}}
 +
 
 +
If you get the "No outputs have backlight property" error, it is because xrandr/xbacklight does not choose the right directory in {{ic|/sys/class/backlight}}. You can specify the directory by setting the {{ic|Backlight}} option of the device section in {{ic|/etc/X11/xorg.conf.d/20-''video''.conf}}. For instance, if the name of the directory is {{ic|intel_backlight}} and using the [[Intel]] driver, the device section may be configured as follows:
 +
 
 +
{{hc|/etc/X11/xorg.conf.d/20-intel.conf|
 +
Section "Device"
 +
    Identifier  "Intel Graphics"
 +
    Driver      "intel"
 +
    Option      "Backlight"  "intel_backlight"
 +
EndSection}}
 +
 
 +
See {{Bug|27677}} and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=651741 for details.
 +
 
 +
=== setpci ===
  
===setpci (use with great care)===
 
 
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.
 
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.
  
Line 125: Line 281:
 
  # setpci -s 00:02.0 F4.B=0
 
  # setpci -s 00:02.0 F4.B=0
  
===Calise===
+
=== Using DBus with Gnome ===
The software [http://calise.sourceforge.net/wordpress/ calise] can be found in AUR.
+
 
* Stable version: {{AUR|calise}}
+
Brightness can also be adjusted as the gnome controls do. Changes are reflected in the gnome UI using this method.
* Development version: {{AUR|calise-git}}  
+
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 contol 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
 +
 
 +
== Color correction ==
 +
 
 +
* {{App|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 {{Pkg|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|{{AUR|clight-git}}}}
 +
* {{App|Monica|Monitor calibration tool. It works as frontend to xgamma to alter the gamma correction.|https://web.archive.org/web/20090815224839/http://www.pcbypaul.com/software/monica.html|{{Pkg|monica}}}}
 +
* {{App|[[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 [[Wikipedia:f.lux|f.lux]].|http://jonls.dk/redshift/|{{Pkg|redshift}}}}
 +
* {{App|xcalib|Lightweight monitor calibration loader which can load an ICC monitor profile to be shared across desktop applications.|https://github.com/OpenICC/xcalib|{{AUR|xcalib}}}}
 +
* {{App|xgamma|Alter a monitor's gamma correction.|https://xorg.freedesktop.org/|{{Pkg|xorg-xgamma}}}}
 +
 
 +
=== xcalib ===
  
It basically computes ambient brightness, and set screen's correct backlight, simply making captures from the webcam, for laptop without light sensor.
+
{{Note|''xcalib'' does ''not'' change the backlight power, it just modifies the video LUT 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). Use {{ic|xcalib -clear}} to reset the LUT.}}
For more information, calise has its own wiki: [http://calise.sourceforge.net/mediawiki/index.php/Main_Page Calise wiki].
 
  
The main features of this program are that it is very precise, very light on resource usage, and with the daemon version (.service file for systemd users available too), it has practically no impact on battery life.
+
The package {{AUR|xcalib}} ([http://xcalib.sourceforge.net/ upstream URL]) is available in the [[AUR]] and can be used to dim the screen. A demonstration video is available on [https://www.youtube.com/watch?v=A9xsvntT6i4 YouTube]. This program can correct gamma, invert colors, and reduce contrast, the latter of which we use in this case. For example, to dim down:
  
===brightd===
+
$ xcalib -co 40 -a
Macbook-inspired {{AUR|brightd}} automatically dims (but does not put to standby) the screen when there is no user input for some time. A good companion of [[Display Power Management Signaling]] so that the screen does not blank out in a sudden.
 
  
== KDE ==
+
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.
[[KDE]] users can adjust the backlight via System Settings -> Power Management -> Power Profiles.
 
If you want set backlight before kdm just put in /usr/share/config/kdm/Xsetup :
 
  
xbacklight -inc 10
+
=== NVIDIA settings ===
  
== NVIDIA Settings ==
 
 
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users 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.)
 
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users 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.)
  
== Backlight PWM modulation frequency (Intel i915 only) ==
+
=== Increase brightness above maximum level ===
Laptops with LED backlight are known to have screen flicker sometimes. The reason for this, is that it is hard enough to dim LEDs by limiting direct current flowing through. It is easier to control brightness by switching LEDs on and off fast enough.
+
 
 +
You can use [[xrandr]] to increase brightness above its maximum level:
 +
 
 +
$ xrandr --output ''output_name'' --brightness 2
 +
 
 +
This will set the brightness level to 200%. It will cause higher power usage and sacrifice color quality for brightness, nevertheless it is particularly suited for situations where the ambient light is very bright (e.g. sunlight).
  
However, frequency of the switching (so-called PWM modulation frequency) is not high enough actually, and some people may notice flicker either explicitly or by feeling headache and eyestrain.
+
== External monitors ==
  
If you have an Intel i915 GPU, then it may be possible to adjust PWM modulation frequency to eliminate flicker.
+
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]] {{ic|i2c-dev}} may need to be loaded if the {{ic|/dev/i2c-*}} devices do not exist.
  
Install intel-gpu-tools from community repo
+
[http://www.ddcutil.com/ ddcutil] can be used to query and set brightness settings:
  
# pacman -S intel-gpu-tools
+
{{hc|# ddcutil capabilities {{!}} grep "Feature: 10"|
 +
  Feature: 10 (Brightness)
 +
}}
  
Get value of the register, that determines PWM modulation frequency
+
{{hc|1=# ddcutil getvcp 10|2=
 +
VCP code 0x10 (Brightness                    ): current value =    60, max value =  100
 +
}}
  
  # intel_reg_read 0xC8254
+
  # ddcutil setvcp 10 70
0xC8254 : 0x12281228
 
  
The value returned represents period of PWM modulation. So to increase PWM modulation frequency, value of the register has to be reduced. For example, to double frequency from the previous listing, execute
+
Alternatively, one may use {{AUR|ddcci-driver-linux-dkms}} to expose external monitors in sysfs. Then, after loading the {{ic|ddcci}} [[kernel module]], one can use any [[#Backlight utilities|backlight utility]].
  
  # intel_reg_write 0xC8254 0x09140914
+
== 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 {{ic|0xC8254}} register (if you are using the Intel GM45 chipset use address {{ic|0x61254}} instead). To manipulate registers values install {{Pkg|intel-gpu-tools}} from the official repositories.
 +
 
 +
To increase the frequency, period must be reduced. For example:
 +
 
 +
{{hc|# intel_reg read 0xC8254|
 +
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:
 +
 
 +
  # intel_reg write 0xC8254 0x09141228
  
 
You can use online calculator to calculate desired value http://devbraindom.blogspot.com/2013/03/eliminate-led-screen-flicker-with-intel.html
 
You can use online calculator to calculate desired value http://devbraindom.blogspot.com/2013/03/eliminate-led-screen-flicker-with-intel.html
  
Refer to dedicated topic for details https://bbs.archlinux.org/viewtopic.php?pid=1245913
+
To set new frequency automatically, consider writing an udev rule or install {{AUR|intelpwm-udev}}.
 +
 
 +
=== Inverted Brightness (Intel i915 only) ===
 +
 
 +
Symptoms:
 +
* after installing {{ic|xf86-video-intel}} 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 {{ic|i915.invert_brightness&#61;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.[https://www.vesa.org/wp-content/uploads/2010/12/DisplayPort-DevCon-Presentation-eDP-Dec-2010-v3.pdf]
 +
 
 +
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 {{ic|1=i915.enable_dpcd_backlight}} as [[kernel parameter]] or set in {{ic|/etc/modprobe.d/i915.conf}}:
 +
 
 +
{{hc|/etc/modprobe.d/i915.conf|<nowiki>
 +
options i915 enable_dpcd_backlight
 +
</nowiki>}}
 +
 
 +
=== sysfs modified but no brightness change ===
 +
 
 +
{{Note|This behavior and their workarounds have been confirmed on the Dell M6700 with Nvidia K5000m (BIOS version prior to A10) and Clevo P750ZM (Eurocom P5 Pro Extreme) with Nvidia 980m.}}
 +
 
 +
On some systems, the brightness hotkeys on your keyboard correctly modify the values of the acpi interface in {{ic|/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 {{ic|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 {{ic|xbacklight}} each time the value of {{ic|/sys/class/backlight/acpi_video0/actual_brightness}} changes.
 +
 
 +
First [[install]] {{Pkg|inotify-tools}}. Then create a script around inotify that will be launched upon each boot or through [[autostart]].
 +
 
 +
{{hc|/usr/local/bin/xbacklightmon|<nowiki>
 +
#!/bin/sh
 +
 
 +
path=/sys/class/backlight/acpi_video0
 +
 
 +
luminance() {
 +
    read -r level < "$path"/actual_brightness
 +
    factor=$((100 / max))
 +
    printf '%d\n' "$((level * factor))"
 +
}
 +
 
 +
read -r max < "$path"/max_brightness
 +
 
 +
xbacklight -set "$(luminance)"
 +
 
 +
inotifywait -me modify --format '' "$path"/actual_brightness | while read; do
 +
    xbacklight -set "$(luminance)"
 +
done
 +
</nowiki>}}

Latest revision as of 15:38, 26 April 2019

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.

Overview

There are many ways to control brightness of a monitor, laptop or integrated panel (such as the iMac). According to this discussion 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 or the graphic driver.
  • brightness is controlled by HW register through setpci.

All methods are exposed to the user through /sys/class/backlight and xrandr/xbacklight can choose one method to control brightness. It is still not very clear which one xbacklight prefers by default.

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

The name of the folder 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 it is called intel_backlight. In the following example, acpi_video0 is used.

The directory contains the following files and folders:

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

The maximum brightness can be found 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 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:

/etc/udev/rules.d/backlight.rules
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="acpi_video0", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", KERNEL=="acpi_video0", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness"

Kernel command-line options

Sometimes, ACPI does not work well due to different motherboard implementations and ACPI quirks, resulting 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:

/etc/udev/rules.d/81-backlight.rules
# Set backlight level to 8
SUBSYSTEM=="backlight", ACTION=="add", KERNEL=="acpi_video0", ATTR{brightness}="8"
Note: The systemd-backlight service restores the previous backlight brightness level at boot. To prevent conflicts for the above rules, see #systemd-backlight service[broken link: invalid section].
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.

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 xset s could be used.

The following example will toggle the screen saver timeout for a similar result (should be bound to a key):

~/.local/bin/xlcd.sh
#!/usr/bin/dash
read lcd < /tmp/lcd
    if [ "$lcd" -eq "0" ]; then
        xset s
        echo 1 > /tmp/lcd
        sleep 1
        notify-send -t 2000 LCD\ ON
    else
        xset s 3
        echo 0 > /tmp/lcd
        notify-send -t 2000 LCD\ OFF
    fi

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/Restore functionality

The systemd package includes the service systemd-backlight@.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 systemd-backlight@backlight:acpi_video0.service. 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 systemd.restore_state=0. See systemd-backlight@.service(8) for details.

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

The relightAUR package provides an alternative systemd-based method of saving and restoring screen brightness.

Additionally, the brilloAUR and light utilities support save/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

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.

Name Controls keyboard backlights Reacts to ambient brightness Language License Notes Package Homepage
acpilight Yes No Python3 GPL-3.0-or-later "xbacklight" compatible acpilight https://gitlab.com/wavexx/acpilight
brightd No No C GPL-2.0 Dims the screen when there is no user input for some time. brightdAUR http://www.pberndt.com/Programme/Linux/brightd
brillo Yes No C GPL-3.0-only Supports smooth and relative adjustments. brilloAUR https://gitlab.com/cameronnemo/brillo
brightnessctl Yes No C MIT Binary is setuid unless otherwise configured. brightnessctlAUR https://github.com/Hummer12007/brightnessctl
Calise No Yes Python2 GPL-3.0 - caliseAUR http://calise.sourceforge.net
Clight Yes Yes C GPL-3.0-or-later Manages screen temperature and smoothly dims brightness after a timeout. Turns webcam into an ambient light sensor. clightAUR https://github.com/FedeDP/Clight
macbook-lighter Yes Yes Bash,Perl GPL Macbook screen/keyboard backlight CLI and auto-adjust on ambient light. macbook-lighterAUR https://github.com/harttle/macbook-lighter
enlighten No No C GPL-3.0-or-later - enlighten-gitAUR https://github.com/HalosGhost/enlighten
illum No No C AGPL-3.0 Reacts to key presses. illum-gitAUR https://github.com/jmesmon/illum
Light Yes No C GPL-3.0-only Binary is setuid unless otherwise configured. light https://haikarainen.github.io/light
Lux No No Shell MIT - luxAUR https://github.com/Ventto/lux

xbacklight

Brightness can be set using the xorg-xbacklight package.

Note:
  • xbacklight only works with Intel. Radeon does not support the RandR backlight property.
  • xbacklight currently does not work with the modesetting driver [1].

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

Gamma can be set using either the xorg-xrandr or xorg-xgamma package. The following commands create the same effect:

$ xrandr --output LVDS1 --gamma 1.0:1.0:1.0
$ xgamma -rgamma 1 -ggamma 1 -bgamma 1
Tip: These commands can be bound to keyboard keys as described in Keyboard shortcuts#Xorg.

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

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

setpci

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.

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

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 contol 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

Color correction

  • 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 || clight-gitAUR
  • Monica — Monitor calibration tool. It works as frontend to xgamma to alter the gamma correction.
https://web.archive.org/web/20090815224839/http://www.pcbypaul.com/software/monica.html || monica
  • 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.
http://jonls.dk/redshift/ || redshift
  • xcalib — Lightweight monitor calibration loader which can load an ICC monitor profile to be shared across desktop applications.
https://github.com/OpenICC/xcalib || xcalibAUR
  • xgamma — Alter a monitor's gamma correction.
https://xorg.freedesktop.org/ || xorg-xgamma

xcalib

Note: xcalib does not change the backlight power, it just modifies the video LUT 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). Use xcalib -clear to reset the LUT.

The package xcalibAUR (upstream URL) is available in the AUR and can be used to dim the screen. A demonstration video is available on YouTube. This program can correct gamma, invert colors, and reduce contrast, the latter of which we use in this case. For example, to dim down:

$ xcalib -co 40 -a

This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.

NVIDIA settings

Users of NVIDIA's proprietary drivers users 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.)

Increase brightness above maximum level

You can use xrandr to increase brightness above its maximum level:

$ xrandr --output output_name --brightness 2

This will set the brightness level to 200%. It will cause higher power usage and sacrifice color quality for brightness, nevertheless it is particularly suited for situations where the ambient light is very bright (e.g. sunlight).

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 i2c-dev may need to be loaded if the /dev/i2c-* devices do not exist.

ddcutil can be used to query and set brightness settings:

# ddcutil capabilities | grep "Feature: 10"
  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-dkmsAUR to expose external monitors in sysfs. Then, after loading the ddcci kernel module, one can use any backlight utility.

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

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

# intel_reg read 0xC8254
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:

# intel_reg write 0xC8254 0x09141228

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

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

Inverted Brightness (Intel i915 only)

Symptoms:

  • after installing xf86-video-intel 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.[2]

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 as kernel parameter or set in /etc/modprobe.d/i915.conf:

/etc/modprobe.d/i915.conf
options i915 enable_dpcd_backlight

sysfs modified but no brightness change

Note: This behavior and their workarounds have been confirmed on the Dell M6700 with Nvidia K5000m (BIOS version prior to A10) and Clevo P750ZM (Eurocom P5 Pro Extreme) with Nvidia 980m.

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. 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=$((100 / max))
    printf '%d\n' "$((level * factor))"
}

read -r max < "$path"/max_brightness

xbacklight -set "$(luminance)"

inotifywait -me modify --format '' "$path"/actual_brightness | while read; do
    xbacklight -set "$(luminance)"
done