From f7548cccda82477b731dee31032a861573f5be3d Mon Sep 17 00:00:00 2001 From: "Hugo Cartigny (BlueskyFR)" Date: Sat, 1 Mar 2025 20:33:31 +0100 Subject: [PATCH] nixos/light: add minBrightness option Make the minimum brightness level configurable instead of using an arbitrary value of 0.1. --- nixos/modules/programs/light.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nixos/modules/programs/light.nix b/nixos/modules/programs/light.nix index f86aeeb390a7..406b9f105c10 100644 --- a/nixos/modules/programs/light.nix +++ b/nixos/modules/programs/light.nix @@ -49,6 +49,15 @@ in ''; }; + minBrightness = lib.mkOption { + type = lib.types.numbers.between 0 100; + default = 0.1; + description = '' + The minimum authorized brightness value, e.g. to avoid the + display going dark. + ''; + }; + }; }; @@ -63,13 +72,14 @@ in let light = "${pkgs.light}/bin/light"; step = builtins.toString cfg.brightnessKeys.step; + minBrightness = builtins.toString cfg.brightnessKeys.minBrightness; in [ { keys = [ 224 ]; events = [ "key" ]; - # Use minimum brightness 0.1 so the display won't go totally black. - command = "${light} -N 0.1 && ${light} -U ${step}"; + # -N is used to ensure that value >= minBrightness + command = "${light} -N ${minBrightness} && ${light} -U ${step}"; } { keys = [ 225 ];