External Monitor Brightness Adjustment
If you haven’t heard already, I bought an external monitor and you can read about it in my previous post. After setting it up, I found there was a problem. I cannot change the brightness of the external monitor with my usual key bindings from Linux. Of course I can manually change the brightness on the monitor itself, but that is old school.
Some Google searches later, I found that there is something called DDC/CI (Display Data Channel Command Interface) which lets the brigntness of the monitor to be controlled from software. Yup, that is what I need. So I added the following to my nix files.
hardware = {
i2c.enable = true;
};
environment.systemPackages = with pkgs; [
ddcutil
ddcui
];
boot = {
kernelModules = [ ... "i2c-dev" ];
};
There is just one problem with this though. I was unable to change brightness as a regular user. Only root user was able to change the brightness of the screen. After much searching, I found out that I need to add myself (username) to the i2c group and add some udev rules. So I added the following
users.users.<my user name> = {
extraGroups = [ ... "i2c" ];
};
services = {
udev = {
extraRules = ''
KERNEL=="i2c-[0-9]*", GROUP="i2c", MODE="0660"
'';
};
}'
From here on, I was able to adjust the brightness using ddcutil as a regular user. However, I wanted the brightness to be adjusted using a keybind in Niri. Since I use Noctalia with Niri, it was a simple configuration change to ~/.config/noctalia/config.toml.
[brightness]
enable_ddcutil = true
sync_all_monitors = true
I wanted my laptop brightness to be in sync with the external monitor brightness since they almost have similar peak brightness (250 nits on my laptop and 300 nits on my monitor). I already have the correct key bindings in ~/.config/niri/config.kdl.
XF86MonBrightnessUp allow-when-locked=true { spawn "noctalia" "msg" "brightness-up 10%"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "noctalia" "msg" "brightness-down 10%"; }
Thats it for my daily routine for that day.