Automatically adjust Linux display brightness
The auto-adjust-display-brightness program automatically adjusts the brightness of Linux computer displays based on whether it’s light or dark outside. To get it working you create a configuration file defining your physical location (this is how it figures out whether it’s light or dark outside) and how to manage the brightness of which displays (so it knows the best way to control the brightness).
I’m a computer programmer and sometimes work through the evening and into the night because it enables deep concentration. During such evenings / nights a recurring irritation was that I had to manually adjust the brightness of my laptop screen and the external monitor attached to my laptop to avoid unnecessary eye strain. I’d been using xflux for years (it removes the blue light from computer displays during the evening) but that doesn’t dim the backlight of my MacBook Air while I found this to be essential to avoid eye strain.
The auto-adjust-display-brightness program is written in Python and is available on PyPI which means installation should be as simple as:
$ pip install auto-adjust-display-brightness
There’s actually a multitude of ways to install Python packages (e.g. the per user site-packages directory, virtual environments or just installing system wide) and I have no intention of getting into that discussion here, so if this intimidates you then read up on your options before returning to these instructions ;-).
The auto-adjust-display-brightness program requires a configuration file that defines your physical location (this is how it figures out whether it’s light or dark outside) and how to manage the brightness of which displays (so it knows the best way to control the brightness). As an example here’s the configuration file that I’m using at the moment:
# My physical location. I determined these values using Google Maps. [location] latitude = 53.240534499999995 longitude = 6.614897599999949 elevation = -2 # The laptop screen of my MacBook Air. This controls the physical backlight # which is the best way to reduce the brightness (it also reduces power # consumption :-). [display:MacBook Air] min-brightness = 7 max-brightness = 70 sys-directory = /sys/class/backlight/acpi_video0 # My external monitor connected via a display port to DVI adapter. I haven't # found any way to configure the physical backlight of this monitor so I'm # resorting to a software only modification here (better than nothing). [display:ASUS monitor] min-brightness = 30 max-brightness = 60 output-name = HDMI1
The configuration file is loaded from the following locations:
The structure of the configuration file is as follows:
To actually have your display brightness adjusted without manually running any commands you can run auto-adjust-display-brightness from a cron schedule. Here’s what I’m currently using:
# /etc/cron.d/auto-adjust-display-brightness: # Crontab entries for automatic adjustment of display brightness. DISPLAY=:0 HOME=/home/peter VIRTUAL_ENV=/home/peter/.virtualenvs/auto-adjust-display-brightness @reboot root $VIRTUAL_ENV/bin/auto-adjust-display-brightness --force 1>/dev/null 2>&1 * * * * * root $VIRTUAL_ENV/bin/auto-adjust-display-brightness 1>/dev/null 2>&1
Some notes about this crontab:
The latest version of auto-adjust-display-brightness is available on PyPI and GitHub. For bug reports please create an issue on GitHub. If you have questions, suggestions, etc. feel free to send me an e-mail at email@example.com.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|auto-adjust-display-brightness-1.3.1.tar.gz (15.3 kB) Copy SHA256 Checksum SHA256||–||Source||Apr 17, 2017|