nixos/modules/light-actkbd.nix

47 lines
912 B
Nix

{pkgs, ...}: let
light = "${pkgs.light}/bin/light";
decLight = pkgs.writeScriptBin "decrease-light-smartly" ''
#!${pkgs.fish}/bin/fish
set curr (${light} -G)
if test $curr -le 5.00 -a $curr -gt 1.00
${light} -S 1
else
${light} -U 10
end
'';
incLight = pkgs.writeScriptBin "increase-light-smartly" ''
#!${pkgs.fish}/bin/fish
set curr (${light} -G)
if test $curr -eq 0.00
${light} -S 1
else
${light} -A 10
end
'';
in {
programs.light.enable = true;
environment.systemPackages = [incLight decLight pkgs.fish];
services.actkbd = {
enable = true;
bindings = [
{
keys = [225];
events = ["key"];
command = "${incLight}/bin/increase-light-smartly";
}
{
keys = [224];
events = ["key"];
command = "${decLight}/bin/decrease-light-smartly";
}
];
};
}