I have a desktop connected to two external monitors. I usually change the brightness and contrast of these monitors multiple times a day and I’d like to have an easy way to change the brightness and contrast.
So far, I’ve mostly been following the answers on this stackexchange question. Using this answer I was able to some scripts to change the brightness and contrast.
However, I’d rather have a slider I can adjust. This other answer states that the ddcci-backlight module should enable the brightness slider:
The DDC/CI kernel module includes a ddcci-backlight module which can integrate most DDC/CI-capable monitors into the kernel’s backlight system ( /sys/class/backlight ). This allows any tool which can use the latter to drive the backlight on a DDC/CI monitor.
After some googling I found the ddcci-driver kernel module, which I enabled by including boot.extraModulePackages = with config.boot.kernelPackages; [ ddcci-driver ];
in my configuration.nix. However, this doesn’t change anything. No slider shows up in the power management, and when I install acpilight and try to change the brightness it seems to have no effect. Also, when I list the devices no monitor seems to show up:
I haven’t done anything with kernel modules before and it feels like I’m missing steps here. Is there anyone who got brightness control for external monitors working on NixOS? I can’t imagine that I’m the only one who wants this, yet I can barely find any information on it.
in my configuration.nix file, but this doesn’t work. Maybe I need a newer version of the KDE (or at least the configuration file). Not sure, I’m not so experienced with NixOS…
Thanks, but I get a ‘option does not exist’ error:
ruben@nixos> sudo nixos-rebuild switch ~
building Nix...
building the system configuration...
error: The option `services.xserver.desktopManager.plasma5.supportDDC' defined in `/etc/nixos/configuration.nix' does not exist.
(use '--show-trace' to show detailed location information)
Ah, that bit is only in unstable. If you’re on the 20.03 (and want to stay on a release channel), you’ll have to wait for 20.09. Alternatively, you can just switch to unstable which is what I’m doing on on workstations.
For me, the issue was that the proprietary nvidia driver doesn’t work correctly with ddcci. I found a way to force the display to be detected by the ddcci driver correctly. But you have to wait until after the i2c device shows up before you can force it, and the kernel module has to be loaded after that. Since I couldn’t find a proper systemd dependency to do this at the right time, I just threw the necessary commands in displayManager.setupCommands.
Looks like the ddcci_backlight kernel module is now active by default.
I’m also on Nvidia and weirdly, I have to run the detection forcing (echo ddcci 0x37 > /sys/bus/i2c/devices/$1/new_device) from my user session, and with a substantial delay (around 10s after X comes up) otherwise there is some kind of race condition and the devices never show up in /sys/class/backlight.
I’ve also found in recent nixos-unstable revisions that I have to delay the echo ddcci 0x37 part, so now the script in my service from the comment above looks like this:
echo Trying to attach ddcci to $1
i=0
id=$(echo $1 | cut -d "-" -f 2)
counter=5
while [ $counter -gt 0 ]; do
if ${pkgs.ddcutil}/bin/ddcutil getvcp 10 -b $id; then
echo ddcci 0x37 > /sys/bus/i2c/devices/$1/new_device
break
fi
sleep 1
counter=$((counter - 1))
done
But otherwise, it works the same with the udev rule, so I don’t have to do anything manually other than make sure to give it a second before logging in and starting Gnome (otherwise Gnome doesn’t pick up the backlight that appears after logging in).
Love your solution, for some reason I’m not getting any i2c-dev udev events, even with the i2c-dev kernel module loaded but I guess that doesn’t really belong in this thread.
For folks who might need it in the future, here’s a bunch of things I used for my AMD GPU. This exposes the monitor under /sys/class/backlight and lets me write to the brightness file without root. I’m not sure whether all the configuration here is absolutely necessary, but it works!