My monitors are colour calibrated using a colorimeter for photographic work, which requires the monitor brightness to be set at a specific level for colour accuracy. During general use in the evenings however I always lower the brightness to avoid eye strain. On laptops this is easy, as you can simply use the brightness keys. But many monitors make this cumbersome, with a slow, clunky interface. As I find myself performing this task twice daily it's a good candidate for automation.

The Display Data Channel Control Interface makes this quite straightforward on Linux using the ddcontrol command. I have one script to set the monitor brightness up to my preferred daytime/photography level and another to turn it down at night. The laptop screen is controlled from the same script using the KDE Plasma desktop's dbus power management controls, so the same scripts control both screens.

The external display device identifier can be found using sudo i2cdetect -l

#!/bin/bash

qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl setBrightness 49
pkexec ddccontrol dev:/dev/i2c-5 -r 0x10 -w 23
#!/bin/bash

qdbus org.kde.Solid.PowerManagement /org/kde/Solid/PowerManagement/Actions/BrightnessControl setBrightness 27
pkexec ddccontrol dev:/dev/i2c-5 -r 0x10 -w 8

I've added two shortcuts to the top panel so that these scripts can be executed with a click.

Previous Post Next Post