Skip to content

Commit 75cd88f

Browse files
authored
nixos/light: add minBrightness option (#386182)
2 parents 41bb262 + f7548cc commit 75cd88f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

nixos/modules/programs/light.nix

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ in
4949
'';
5050
};
5151

52+
minBrightness = lib.mkOption {
53+
type = lib.types.numbers.between 0 100;
54+
default = 0.1;
55+
description = ''
56+
The minimum authorized brightness value, e.g. to avoid the
57+
display going dark.
58+
'';
59+
};
60+
5261
};
5362

5463
};
@@ -63,13 +72,14 @@ in
6372
let
6473
light = "${pkgs.light}/bin/light";
6574
step = builtins.toString cfg.brightnessKeys.step;
75+
minBrightness = builtins.toString cfg.brightnessKeys.minBrightness;
6676
in
6777
[
6878
{
6979
keys = [ 224 ];
7080
events = [ "key" ];
71-
# Use minimum brightness 0.1 so the display won't go totally black.
72-
command = "${light} -N 0.1 && ${light} -U ${step}";
81+
# -N is used to ensure that value >= minBrightness
82+
command = "${light} -N ${minBrightness} && ${light} -U ${step}";
7383
}
7484
{
7585
keys = [ 225 ];

0 commit comments

Comments
 (0)