Clight is a tool that uses your computer’s webcam or ambient light sensors to get the ambient brightness, and then calculates and sets the screen backlight accordingly.
Besides adjusting the screen backlight based on ambient brightness, this program can also adjust the keyboard backlight, and manage the screen temperature (GAMMA support) based on sunset and sunrise times, similar to Redshit. External monitors are also supported. It can also dim your screen after a period of inactivity and manage the screen DPMS.
The tool works on X11, Wayland and tty, although on Wayland, some protocols need to be implemented by your compositor for this to work.
Clight itself is a daemon (written in C), so it doesn’t have a graphical user interface, however, there’s a cool third-party Qt 5/6 GUI that you can use, which allows configuring Clight, which comes with a tray applet:
It’s important to note that Clight is lightweight, and it aims to be very power friendly, only using CPU when needed. So it shouldn’t drain your laptop’s battery. It won’t use the camera all the time, but only when it’s needed, with longer timeouts while on battery.
- Per-user configuration file support
- Detects whenever a USB webcam is attached/detached and consequently resumes/pauses backlight module
- Ambient brightness-based GAMMA; it means that screen temperature will be updated to match ambient brightness instead of sunrise/sunset based, using same curve specified for backlight (this is besides the ability to automatically change screen temperature based on sunset and sunrise times)
- The sunset / sunrise times can be acquired automatically using geoclue2 (which is used to get the user location), or the user can specify the sunset / sunrise times manually
- Simple SCREEN-emitted light compensation support
- Smooth GAMMA/DIMMER/BACKLIGHT transitions
- UPower support, to set longer timeouts between captures while on battery, in order to save some energy
- Docked state support, for laptops: when laptop lid is closed, “Docked” state is checked. It can manage a “Docked” state as an inhibtion for DIMMER and DPMS
- org.freedesktop.ScreenSaver interface support. Thus, when for example watching a YouTube video from Chromium, DIMMER and DPMS will be inhibited
- Dbus interface that can be used to create scripts for example, autocompletion script for bash, custom modules, lots of configuration options available, and more
Related: Gammy: Adaptive Screen Brightness Tool For Linux
Installing Clight (and optionally Clight-GUI)
The only downside to Clight? You need to build not only Clight and Clightd from source, but also 2 dependencies (libmodule and ddcutil), as well as the Clight-GUI if you want to use it. That is, unless you use Arch Linux / Manjaro (there are AUR packages available), NixOS, Exherbo or Void Linux, for which there are packages available.
On the Clight wiki you’ll find the required dependencies (well, some of them), along with commands to install these on Debian / Ubuntu / Linux Mint / Pop!_OS and Fedora.
Note that for Debian / Ubuntu / Linux Mint / Pop!_OS, besides the command to install the dependencies from the Clight Wiki, you’ll also need the following packages in order to build Clight, Clightd and their 2 dependencies (libmodule and ddcutil):
libdbus1-dev libudev-dev libjpeg-turbo8-dev libpolkit-gobject-1-dev libdrm-dev libglib2.0-dev libusb-1.0-0-dev libtool autoconf autotools-dev libx11-dev libxrandr-dev libxext-dev libwayland-dev.
You’ll also need to make sure you have
git installed to pull the repositories from GitHub. You may also install (optional)
libgeoclue-2-dev to automatically retrieve user location for sunset / sunlight times.
Once you have all these pakages installed, use this script to build and install Clight, Clightd, ddcutils and libmodule.
For Clight-GUI you’ll also need to install
libqt5charts5-dev on Debian / Ubuntu. Also, on my Ubuntu 20.04 desktop, Clight-GUI failed to build (it didn’t on Ubuntu 20.10), getting an error saying “DBusSingle.h:20 Error: Not a signal or slot declaration”. I fixed this by opening
clight-gui/src/dbus/DBusSingle.h, and on line 19 I removed “slots” (so it’s just “public:” now).
It’s also worth noting that to be able to see the Clight-GUI on GNOME Shell, you’ll need an extension such as AppIndicator and KStatusNotifierItem Support (this is installed by default on Ubuntu, so you don’t need to install anything).
Clight-GUI uses a dark tray icon by default so, depending on the color of your panel, you might not see it at all – fix this by setting Clight-GUI to use a light tray icon from its Tray menu (Light Tray Icon option).
Also, some recent geoclue2 versions will cause the Clight startup time to increase by up to 20 seconds.
Related: Change Shell / GTK Theme To Dark Variant When GNOME Night Light Is On