nixos/modules/light-actkbd.nix

47 lines
912 B
Nix
Raw Normal View History

{pkgs, ...}: let
2021-06-01 22:42:38 +02:00
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
2021-08-16 16:17:55 +02:00
${light} -U 10
2021-06-01 22:42:38 +02:00
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
2021-08-16 16:17:55 +02:00
${light} -A 10
2021-06-01 22:42:38 +02:00
end
'';
in {
programs.light.enable = true;
environment.systemPackages = [incLight decLight pkgs.fish];
2021-06-01 22:42:38 +02:00
services.actkbd = {
enable = true;
bindings = [
2021-05-23 16:00:37 +02:00
{
keys = [225];
events = ["key"];
2021-06-01 22:42:38 +02:00
command = "${incLight}/bin/increase-light-smartly";
}
2021-05-23 16:00:37 +02:00
{
keys = [224];
events = ["key"];
2021-06-01 22:42:38 +02:00
command = "${decLight}/bin/decrease-light-smartly";
}
];
};
}