[i3] Setup brightness control with ddcutil

This commit is contained in:
2025-11-19 19:41:50 -08:00
parent 4f6d65316a
commit a9772259f0
2 changed files with 27 additions and 5 deletions

View File

@@ -87,8 +87,8 @@ let
"${shared_config.modifier}+r" = "mode resize"; "${shared_config.modifier}+r" = "mode resize";
"XF86MonBrightnessUp" = "exec brightnessctl s +5%"; "XF86MonBrightnessUp" = "exec ddcutil setvcp 10 + 5";
"XF86MonBrightnessDown" = "exec brightnessctl s 5%-"; "XF86MonBrightnessDown" = "exec ddcutil setvcp 10 - 5";
}; };
} cfg.extraSharedConfig; } cfg.extraSharedConfig;
in { in {
@@ -149,11 +149,21 @@ in {
[backlight] [backlight]
command=${pkgs.writeShellScript "i3blocks-backlight" '' command=${pkgs.writeShellScript "i3blocks-backlight" ''
if command -v brightnessctl &>/dev/null; then if command -v ddcutil &>/dev/null; then
brightnessctl g | awk -v max=$(brightnessctl m) '{printf " %.0f%%\n", ($1/max)*100}' # Handle mouse scroll events
case $BLOCK_BUTTON in
4) ddcutil setvcp 10 + 5 ;; # Scroll up - increase brightness
5) ddcutil setvcp 10 - 5 ;; # Scroll down - decrease brightness
esac
# Display current brightness
brightness=$(ddcutil getvcp 10 2>/dev/null | grep -oP 'current value =\s*\K\d+')
if [ -n "$brightness" ]; then
echo " $brightness%"
fi
fi fi
''} ''}
interval=1 interval=5
separator=true separator=true
[network] [network]

View File

@@ -19,8 +19,20 @@ in
polkit_gnome # GNOME polkit authentication agent (more stable with i3) polkit_gnome # GNOME polkit authentication agent (more stable with i3)
picom # Compositor for smooth rendering (important for Nvidia) picom # Compositor for smooth rendering (important for Nvidia)
networkmanagerapplet # NetworkManager system tray applet networkmanagerapplet # NetworkManager system tray applet
ddcutil # DDC/CI monitor control for brightness
]; ];
}; };
}; };
# Enable DDC/CI support for monitor brightness control
boot.kernelModules = [ "i2c-dev" ];
# Add ddcutil udev rules and user permissions
hardware.i2c.enable = true;
# Install ddcutil system-wide
environment.systemPackages = with pkgs; [
ddcutil
];
}; };
} }