backlight-auto

The missing backlight auto adjusting program for Linux.

Tired of adjusting brightness going from place to place?

Has the sun gone down and not realize you're burning out your eyes?

Want to adjust certain monitor's brightness using certain video sources?

Looking for a tool that has 2 dependencies and gets the job done?

backlight-auto is here to help.

Installation

Unfortunately backlight-auto is not yet packaged for distributions. If you're a package manager I'd love to help you package this.

The first step is to install Zig.

The second step is to install libyuv and video4linux2 headers.

For both of those steps, please use a search engine. The instructions change all the time.

Third, save this embedded zip (you've already downloaded it if you're viewing this page) which contains the whole project and its git repository:

download.zip

Last, build the project with `zig build` and copy `zig-out/bin/backlight-auto` to your preferred place.

Usage

There are multiple ways to setup using backlight-auto, but the first step is to tell the program what your webcam sees as "black".

To start, place your thumb over your webcam.

Run `backlight-auto --measure --path-dev-video /dev/video0`.

Take the number printed and pass it into backlight-auto when you run it normally.

`backlight-auto --min-stimulus-length 1.48554e+02 --path-dev-video /dev/video0 --path-backlight /sys/class/backlight/intel_backlight/`

The program will output the recommended brightness value to be placed in the `/sys/class/backlight/X/brightness` file.

I personally use the `brightnessctl` program, like so: `brightnessctl s $(backlight-auto ...)`.

To run it periodically, create a systemd file.

I personally assign it to a function key and run it when needed.

For example, in i3wm's configuration file, I use this line:

bindsym XF86Favorites exec brightnessctl s $(/home/lee/bin/backlight-auto --min-stimulus-length 1.47808837e+02 --path-dev-video /dev/video0 --path-backlight /sys/class/backlight/intel_backlight/)

Information

The brightness calculation from the video input is based off the paper called "Brightness Calculation in Digital Image Processing" by Sergey Bezryadin, Pavel Bourov, and Dmitry Ilinih from January 2007.

It takes by default 4 seconds to let the webcam "get hot", i.e. get proper exposure. This can be adjusted by passing `--sample-time some-number`.

Contributions

Email len@falken.directory with suggestions or patches.

This tool is small, with the aim to be naturally forked and maintained forever.

This software is evolutionary. The strongest fork is the official fork.