Unverified Commit 75cd88fa authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

nixos/light: add minBrightness option (#386182)

parents 41bb262e f7548ccc
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -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 ];