In brief, this Python tool, tested only on Linux, will automatically adjust your screen brightness based on the ambient light around you, as detected by your webcam. This small tool is still in the early stages of development, and honestly I may not spend much more time on it unless I get some encouragement/feedback that anyone finds it useful, ha. That said, I’ve been using it extensively on several laptops running Arch Linux. I recommend mapping keyboard key to launch this for best results. You could also run it via cron/systemd set to execute every few minutes or something.
Project Page: https://bitbucket.org/agaskins/ccbl/
Requires Python 2.x. ‘ccbl.py’ is all you need. It might work for you as-is, but before you run the script it’s worth giving the source code a glance to make sure your camera device is specified correctly. For me, as you can see in the code, it was /dev/video0, but it could be different for your system.
From the README file:
‘ccbl’ stands for ‘Camera-controlled Backlight’. It is an application
that sets the brightness of a display panel based on ambient light as
derived from the web-cam.
Although many newer laptops come with sensors to detect ambient light,
many still don’t have this technology, or it just doesn’t work on Linux
in some cases, but almost all modern laptops have cameras these days so
I decided this was a reasonably sane and consistent way to go about it.
Right now the main goal of the project is to be as simple and minimal as
possible, but in the future the application may become more robust,
allowing it to choose the best method available and such (i.e. if the
system has both a camera and an ambient light sensor, ‘ccbl’ would
choose to use the latter). Even if I do create a GUI for this, I will
always keep the basic back-end a simple script that can be ran from a
command line so that one can use this tool from other scripts, as a
key-binding, a cron job, etc.
This script aims to be as minimal as possible. While it is possible to
change the backlight settings without an external tool there seems to be
no particularly consistant method for doing so. Therefore, I decided to
use the xbacklight tool as the interface to change backlight settings.
It’s a tiny app and it is pre-installed on many Linux distros, and where
it is not included you can typically find it as a standard tool available
for installation in almost every distro’s package repo. In arch, which I
use, the package you will want to install is named ‘xorg-xbacklight’. On
many other systems you simply install ‘xbacklight’ (the case for Debain).
In the future I may find a method that does not require a non-python
dependency at all, and thus liberate ‘ccbl’ from dependencies entirely.
If you have ideas, tips or suggestions feel free to email them to me.