diff options
author | tomberek <tomberek@users.noreply.github.com> | 2024-01-26 02:43:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-26 02:43:19 -0500 |
commit | 7aea9330a6df841580c58abca5577d7f145f2710 (patch) | |
tree | 316d9ad278d64c2d0662ef18dfec6e5a66d64405 /nixos | |
parent | 79633fea6d408b910fabcaa07a02a72860b0a85a (diff) | |
parent | 5e329241e8b5c25e17e3a852323890d25cd271d9 (diff) | |
download | nixlib-7aea9330a6df841580c58abca5577d7f145f2710.tar nixlib-7aea9330a6df841580c58abca5577d7f145f2710.tar.gz nixlib-7aea9330a6df841580c58abca5577d7f145f2710.tar.bz2 nixlib-7aea9330a6df841580c58abca5577d7f145f2710.tar.lz nixlib-7aea9330a6df841580c58abca5577d7f145f2710.tar.xz nixlib-7aea9330a6df841580c58abca5577d7f145f2710.tar.zst nixlib-7aea9330a6df841580c58abca5577d7f145f2710.zip |
Merge pull request #60804 from jluttine/add-brightness-keys-to-light
light: support brightness control keys
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/programs/light.nix | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/nixos/modules/programs/light.nix b/nixos/modules/programs/light.nix index 57cc925be465..1cdf22a7699d 100644 --- a/nixos/modules/programs/light.nix +++ b/nixos/modules/programs/light.nix @@ -9,6 +9,7 @@ in { options = { programs.light = { + enable = mkOption { default = false; type = types.bool; @@ -17,11 +18,60 @@ in and udev rules granting access to members of the "video" group. ''; }; + + brightnessKeys = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Whether to enable brightness control with keyboard keys. + + This is mainly useful for minimalistic (desktop) environments. You + may want to leave this disabled if you run a feature-rich desktop + environment such as KDE, GNOME or Xfce as those handle the + brightness keys themselves. However, enabling brightness control + with this setting makes the control independent of X, so the keys + work in non-graphical ttys, so you might want to consider using this + instead of the default offered by the desktop environment. + + Enabling this will turn on {option}`services.actkbd`. + ''; + }; + + step = mkOption { + type = types.int; + default = 10; + description = '' + The percentage value by which to increase/decrease brightness. + ''; + }; + + }; + }; }; config = mkIf cfg.enable { environment.systemPackages = [ pkgs.light ]; services.udev.packages = [ pkgs.light ]; + services.actkbd = mkIf cfg.brightnessKeys.enable { + enable = true; + bindings = let + light = "${pkgs.light}/bin/light"; + step = toString cfg.brightnessKeys.step; + 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}"; + } + { + keys = [ 225 ]; + events = [ "key" ]; + command = "${light} -A ${step}"; + } + ]; + }; }; } |