2014-11-10 02:32:11 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.light;
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
programs.light = {
|
2019-05-02 20:42:53 +00:00
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
enable = lib.mkOption {
|
2014-11-10 02:32:11 +00:00
|
|
|
default = false;
|
2024-04-17 11:37:58 +00:00
|
|
|
type = lib.types.bool;
|
2014-11-10 02:32:11 +00:00
|
|
|
description = ''
|
2018-10-01 02:16:56 +00:00
|
|
|
Whether to install Light backlight control command
|
|
|
|
and udev rules granting access to members of the "video" group.
|
2014-11-10 02:32:11 +00:00
|
|
|
'';
|
|
|
|
};
|
2019-05-02 20:42:53 +00:00
|
|
|
|
|
|
|
brightnessKeys = {
|
2024-04-17 11:37:58 +00:00
|
|
|
enable = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2019-05-02 20:42:53 +00:00
|
|
|
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`.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
step = lib.mkOption {
|
|
|
|
type = lib.types.int;
|
2019-05-02 20:42:53 +00:00
|
|
|
default = 10;
|
|
|
|
description = ''
|
|
|
|
The percentage value by which to increase/decrease brightness.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-11-10 02:32:11 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2014-11-10 02:32:11 +00:00
|
|
|
environment.systemPackages = [ pkgs.light ];
|
2018-09-30 11:11:56 +00:00
|
|
|
services.udev.packages = [ pkgs.light ];
|
2024-04-17 11:37:58 +00:00
|
|
|
services.actkbd = lib.mkIf cfg.brightnessKeys.enable {
|
2019-05-02 20:42:53 +00:00
|
|
|
enable = true;
|
|
|
|
bindings = let
|
|
|
|
light = "${pkgs.light}/bin/light";
|
2024-04-17 11:37:58 +00:00
|
|
|
step = builtins.toString cfg.brightnessKeys.step;
|
2019-05-02 20:42:53 +00:00
|
|
|
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}";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2014-11-10 02:32:11 +00:00
|
|
|
};
|
|
|
|
}
|