Available as/for:arm64armhfrelease-gitsource-packagex86x86-64
Description:Highly reactive daemon for adaptive backlight, using camera as light sensor.
## Features
- smooth backlight adaptation
- delayed start
- one-time mode
- auto-restart on configuration file change
- set maximum light to current by SIGUSR2 signal
- effective: up to 30fps for camera input without notable performance losses
- no need for systemd or X, though xbacklight may be used
## Dependencies
#### Minimum
- POSIX shell (tested with GNU Bash and Dash)
- FFMpeg: https://ffmpeg.org/
- coreutils: https://www.gnu.org/software/coreutils/
- GNU awk: https://www.gnu.org/software/gawk/gawk.html
- v4l-utils: https://git.linuxtv.org/v4l-utils.git
- psmisc: https://gitlab.com/psmisc/psmisc
#### Optional (alternative)
- ncurses: https://www.gnu.org/software/ncurses/ - for colored output
- util-linux: https://www.kernel.org/pub/linux/utils/util-linux/ - use hexdump instead of od
- inotify-tools: https://github.com/inotify-tools/inotify-tools - to auto-restart on configuration change
#### Backlight control backends (optional)
- light: https://github.com/haikarainen/light
- xbacklight: https://gitlab.freedesktop.org/xorg/app/xbacklight) or [acpilight](sys-power/acpilight
Note: It will tell when necessary tools are missing.
# Usage
Run with default settings:
$ backlightadapt
Type `backlightadapt -h` to see all options.
#### Useful options
Toggle running:
$ backlightadapt -t
Match backlight once to current light level and quit:
$ backlightadapt -1
Update maximum light level to current and save:
$ backlightadapt --calibrate
Update configuration from command line options:
$ backlightadapt --update-conf
### Backlight change smoothing
Backlight can change smoothly by using multiple box filter stages. Box filters are effective at any buffer length, and 3 of them are enough to get result, comparable by quality with gaussian or cubic spline. Buffer sizes are specified independently for each filter in form of comma-separated number list (no spaces).
#### Examples for framerate 30fps
Use short anti-fluctuation filter:
$ backlightadapt --smooth 6,6
Slow accomodation filter:
$ backlightadapt --smooth 120,120,20
Note: Two equally sized filters seem to be most optimal setup.
Lone one makes linear transition for lone jump between two stable levels, but for short fluctuation it will be just small but constant change for all duration. 2nd filter turns it to linear fade on and off. This should be enough for usable result - for stable change it makes smooth result. 3rd filter smoothes even shortest fluctuations, but each extra stage adds latency between light change and visible backlight reaction.
## Configuration
Configuration file is automatically created if no other file exists and writeable config directory is found.
Further update may be forced with --update-conf or -u command line option.
#### Locations
- $XDG_CONFIG_DIR
- ~/.config
- /etc
#### Supported signals
- SIGUSR1 - reload configuration
- SIGUSR2 - update maximum light level to current
#### Permissions
Following steps are necessary for internal ACPI backend to work.
- Place '90-backlight.rules' into '/etc/udev/rules.d' or '/lib/udev/rules.d' to enable write permissions for internal ACPI backend (requires reboot).
- Make sure, that you are in video group (requires relogin).
**Note:** other tools like *acpilight* or *light* may have it already done.
## Bug reports
Please report bugs at
github: https://github.com/nick87720z/backlight-adaptive/issues
or opencode: https://www.opencode.net/nick87720z/backlight-adaptive/-/issues
## Under hood
Shell script only makes setup, all dirty job is done by persistant ffmpeg-based pipeline.
## Known alternatives
- Clight: https://github.com/FedeDP/Clight
- calise: https://sourceforge.net/projects/calise/
- macbook-lighter: https://github.com/harttle/macbook-lighter
See more backlight utilities: https://wiki.archlinux.org/index.php/Backlight#Backlight_utilities
Ratings & Comments
23 Comments
awk: command line: 54: fatal error: trying to divide by zero ?
It requires minimum backlight non-zero, because of fading done in logarithmical scale (i.e. fade speed is always relative of current backlight level rather than absolute). Could be avoided with smoothness off (0 frames). Working on it.
Fixed. It will force non-zero minimum when fade enabled. If you really need monitor off, in this way, you could set --bl-min to something like 0.0001, but for me it took half-second after reaching minimum level before monitor turned off (there is already DPMS for power management).
now no errors ... but it probably doesn't work or I have wrong settings? my config acpi_dev = backend_args = backends = internal, light, xbacklight delay = 0.1 fade_frames = 0 grab = true log_color = false log_level = info maxbright = 100 max_color = 35 minbright = 1 watch_conf = true
That looks like default settings. Some sign, that it passes config load/save (it creates new when finds writeable dir and there is still no loaded config to this point). I need to know following: - Program version. Ideally you are better try latest (git) version prior report. Also need to know versions/implementations for dependencies, at least basic. - Special note about awk. For now it needs to be gawk (if you used other implementation like mawk or nawk). - Program output. Try with debug log level. If cli option has no effect, git version has the fix. - Try to disable all features that can be disabled - config watch, log color. - Try different backends (default has them on in list, with later used as fallbacks). E.g.: --backends xbacklight. For xbacklight - ensure it works at all, try this: xbacklight -get. If nothing, you probably need acpilight. - If still no points to error/problem, try this: $ sh -evx ./backlight-adaptive 2>&1 | tee log This will give dozens of output, writing it both to your terminal and to log file (find better filename you like). This should be published via pastebin services.
Did problem resolve? If not, can you please post output from "sh -evx ./backlight-adaptive"?
Now I have: Pipeline terminated on its own + exit
Ok. Please check latest git version. I added permission check for internal backend, so it will tell if permissions are denied.
I ran like this: sudo ./backlight-adaptive started without errors ... but nothing is happening probably bad configuration. But after shutting down and restarting, I got the error: Pipeline terminated on its own
Confirming, it will not work under root (sudo). Without root it's fine.
without sudo Can't write to '/sys/class/backlight/acpi_video0/brightness'
after adding user to video group ... it's OK but I'm getting this error again: Pipeline terminated on its own :-)
What's group for that file? Must be video, not root. Create (copy) file with udev rules to where all rules reside, then reboot.
I think I have something wrong with the system keeps getting: Can't write to '/ sys / class / backlight / acpi_video0 / brightness'
and unfortunately the brightness control does not work at all in my system
https://pastebin.com/ZKNjYBBn
https://easyupload.io/lmbu60
Ah, so, now you can write to that file, right? Please, run script file as "sh -evx file" and show me output.
Will continue here, before maximum post width shrinks to 1-2 characters :D. I don't understand, did you add udev rule and ensure, that /sys/class/backlight/acpi_video0/brightness has video group instead of default root? I repeated this through multiple posts.
What version did you use?
https://www.opencode.net/nick87720z/backlight-adaptive from this page after downloading a tar package ....I did wrong ... uppss :-(
Please check permissions setup in readme (it was to be added in begining). If this doesn't fix, please "sh -evx ./backlight-adaptive" output (this will show, what it does wrong).
There were some fixes, can you test again if it works for you now?