For Ubuntu you can use the installation script:
curl -sSLf https://github.com/jacob-pro/solar-screen-brightness/raw/master/linux/ubuntu_install.sh?raw=true | bash -s install
Internally solar-screen-brightness
uses the brightness
crate.
On Linux, the brightness
crate interacts with devices found at /sys/class/backlight
.
The ddcci-backlight kernel driver is required to expose external monitors as backlight devices (via DDC/CI).
On Ubuntu-like distributions you should be able to use APT to install:
sudo apt install ddcci-dkms
On RHEL-family distributions:
sudo yum install kernel-devel # You need matching kernel headers installed
git clone https://gitlab.com/ddcci-driver-linux/ddcci-driver-linux.git
cd ddcci-driver-linux
sudo make install
sudo make load
If the driver was installed successfully and is working for your monitors, you should now
be able to see the devices listed in both /sys/bus/ddcci/devices
and /sys/class/backlight
.
In one terminal run: dmesg -wT | grep ddcci
to follow the logs.
Then reload the driver in debug mode:
cd ddcci-driver-linux
sudo make unload
modprobe ddcci-backlight dyndbg
If you have systemd
version 243 or later,
then the brightness
crate will attempt to set the device brightness
using the DBus
SetBrightness()
call, which manages all the permissions for you.
However, on older versions which don't have this function, then brightness
must write directly to the backlight file,
which will require you to set appropriate permissions. You can do this using udev
rules, for example:
/etc/udev/rules.d/backlight.rules
RUN+="/bin/bash -c '/bin/chgrp video /sys/class/backlight/*/brightness'"
RUN+="/bin/bash -c '/bin/chmod g+w /sys/class/backlight/*/brightness'"
usermod -a -G video $USER
(requires logging out to take effect)