Controlling the Brightness of an External Monitor under Linux
At home I use an external Monitor (AOC U27P2CA) that is connected via a USB-C cable to my Laptop running PopOS 22.04 on Wayland.
I regularly change the monitor brightness depending on whether its dark outside or not.
This requires me navigating through several submenus and is quite inconvenient.
Using ddccontrl and some custom Shortcuts I can change the brightness directly from the keyboard of my Laptop.
There exist alternatives like ddcutil, those however did not work for me.
I followed the installation instructions provided in the README.
For PopOS 22.04, which is based on Ubuntu those are the following:
Installing
Install the packages:
sudo apt install ddccontrol gddccontrol ddccontrol-db i2c-tools
Restart the system.
The monitor communicates with the Laptop over i2c
protocol. Add your user to the i2c group and make sure that i2c-dev
kernel module is loaded:
sudo adduser $USER i2c
sudo /bin/sh -c 'echo i2c-dev >> /etc/modules'
Launch the graphical utility.
gddccontrol
The utility detected my monitor as dev/i2c-15
(yours may differ) however could not control it. It stated that my monitor was not in the data base.
Communicating with the monitor via the CLI however worked:
Reading the current brightness level can be done via this command. On my machine it also runs without sudo
ddccontrol -r 0x10 dev:/dev/i2c-15
Setting a brightness level (e.g to 75 %) is done like so:
ddccontrol -r 0x10 -w 75 dev:/dev/i2c-15
Using a capital W
it is also possible to increase/decrease the brightness by a specific amount, e.g. 10 %:
ddccontrol -r 0x10 -W +10 dev:/dev/i2c-15
ddccontrol -r 0x10 -W -10 dev:/dev/i2c-15
Changing the brightness via keyboard shortcuts
In the Gnome Keyboard Settings it is possible to define commands that are run upon a custom keyboard short cut.
I defined two custom shortcuts: one for increasing the brightness level by 10 percent points, and a second for decreasing the brightness level by 10 percent points, see the following screenshot:
I used F5 and F6 since they are used to change the brightness (of the Laptop display), just the modifier key is different.
I now can change the brightness of the external monitor from the keyboard of my Laptop.