fbpx

Desktop

Control your monitor in CentOS/RHEL 8

by , , revisited on


We have by far the largest RPM repository with NGINX module packages and VMODs for Varnish. If you want to install NGINX, Varnish, and lots of useful performance/security software with smooth yum upgrades for production use, this is the repository for you.
Active subscription is required.

The ability to adjust brightness of your display using the keyboard of your laptop is a given thing.

However, the same does not apply to desktop machines. Do you want to easily adjust brightness and other settings of your external monitor without touching it?
If so, read on.

You can (almost) fully manage your display thanks to the DDC protocol. It allows your operating system to talk to the display for adjusting its settings.

Command-line software

Geeks may resort to ddcutil for controlling their monitor.
Once installed, you can adjust brightness like this

  1. Lookup the ID of brightness feature:
    ddcutil capabilities | grep Brightness
    # Feature: 10 (Brightness)
    
  2. Get current value:
    ddcutil getvcp 10
    # VCP code 0x10 (Brightness): current value = 60, max value = 100
    
  3. Set brightness to 70:
    ddcutil setvcp 10 70
    

The other option is ddccontrol, which may not always work, depending on your specific monitor.
Why is because the program relies on a database of known monitors to work its best.

The added benefit, though, is that there is a GUI app available if you install ddccontrol-gtk.
Then you can run it with gddcontrol, but have to do so via sudo, which is quite undesired in the first place.

So these command-line options are not for faint-hearted, although may be useful in scripted scenarios. There is something better for day-to-day use.

Gnome backlight controls

Gnome has GUI for controlling the brightness of your display. But this works mostly with laptops.
ddcci-driver-linux creates the necessary backlight devices under /sys/class/backlight/ and makes things magically work.

How to install

sudo dnf install https://extras.getpagespeed.com/release-latest.rpm
sudo dnf install kmod-ddcci
sudo modprobe ddcci_backlight

Then restart your Gnome session by logging out and logging back in (or running gnome-shell --replace).

I should add that (for historical reasons) after playing with NVIDIA drivers which suck in supporting DDC, I had a bunch of weird boot time issues.
The command dracut -f fixed them altogether (after I got rid of the NVIDIA card).

You will see the brightness control when clicked on tray icons.

GNOME display brightness control
GNOME display brightness control

To make this module persistent across reboot, create /etc/modules-load.d/ddcci.conf with contents:

# Load ddcci_backlight.ko at boot
ddcci_backlight

Then reboot. If nothing still works, this is likely a fault in your video driver as detailed here.
The workaround is adding to /etc/rc.local (and make it executable):

# timeout 3 echo 'ddcci 0x37' > /sys/bus/i2c/devices/i2c-<?>/new_device
echo 'ddcci 0x37' | timeout 3 sudo tee /sys/bus/i2c/devices/i2c-1/new_device
sudo modprobe -r ddcci_backlight ddcci
sudo modprobe ddcci_backlight

The i2c-1 above is system-specific. You might the correct value by examining the output of ddcutil detect.

Fully automated

There is a software which will use the same DDC protocol to automatically manage your display brightness using your web-camera, and a lot more – CLight.
However, this doesn’t work reliably in my testing (will contact upstream).

CLight packages are available in our repository for testing:

yum install https://extras.getpagespeed.com/release-latest.rpm
yum install clight

Fixing monitor glitches

I have a weird issue with a monitor sometimes waking up from sleep. It’s possible to leverage ddcutil together with SystemD to fully off the monitor when you put it to sleep.
Create /usr/lib/systemd/system-sleep/monitor.sh and make it executable:

#!/bin/sh

if [ "${1}" == "pre" ]; then
  modprobe -r ddcci_backlight
  ddcutil setvcp d6 4
elif [ "${1}" == "post" ]; then
  ddcutil setvcp d6 1
  # Bring back the backlight module
  modprobe ddcci_backlight 
fi

Note how we have to remove ddci_backlight. This is because only one program/module can control an i2c device at the same time.

This didn’t fix the issue in its entirety, because after putting it to off, it can’t be resumed by ddcutil.

But at least I don’t have to manually turn it off after putting the computer to sleep.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.