at 24.11-pre 2.2 kB view raw
1{ config, lib, pkgs, ... }: 2 3let 4 cfg = config.programs.light; 5 6in 7{ 8 options = { 9 programs.light = { 10 11 enable = lib.mkOption { 12 default = false; 13 type = lib.types.bool; 14 description = '' 15 Whether to install Light backlight control command 16 and udev rules granting access to members of the "video" group. 17 ''; 18 }; 19 20 brightnessKeys = { 21 enable = lib.mkOption { 22 type = lib.types.bool; 23 default = false; 24 description = '' 25 Whether to enable brightness control with keyboard keys. 26 27 This is mainly useful for minimalistic (desktop) environments. You 28 may want to leave this disabled if you run a feature-rich desktop 29 environment such as KDE, GNOME or Xfce as those handle the 30 brightness keys themselves. However, enabling brightness control 31 with this setting makes the control independent of X, so the keys 32 work in non-graphical ttys, so you might want to consider using this 33 instead of the default offered by the desktop environment. 34 35 Enabling this will turn on {option}`services.actkbd`. 36 ''; 37 }; 38 39 step = lib.mkOption { 40 type = lib.types.int; 41 default = 10; 42 description = '' 43 The percentage value by which to increase/decrease brightness. 44 ''; 45 }; 46 47 }; 48 49 }; 50 }; 51 52 config = lib.mkIf cfg.enable { 53 environment.systemPackages = [ pkgs.light ]; 54 services.udev.packages = [ pkgs.light ]; 55 services.actkbd = lib.mkIf cfg.brightnessKeys.enable { 56 enable = true; 57 bindings = let 58 light = "${pkgs.light}/bin/light"; 59 step = builtins.toString cfg.brightnessKeys.step; 60 in [ 61 { 62 keys = [ 224 ]; 63 events = [ "key" ]; 64 # Use minimum brightness 0.1 so the display won't go totally black. 65 command = "${light} -N 0.1 && ${light} -U ${step}"; 66 } 67 { 68 keys = [ 225 ]; 69 events = [ "key" ]; 70 command = "${light} -A ${step}"; 71 } 72 ]; 73 }; 74 }; 75}