Move HM modules

This commit is contained in:
Filippo Berto 2023-07-19 10:42:09 +01:00
parent 5db76d0fed
commit 3cf0004b78
No known key found for this signature in database
GPG key ID: FE98AE5EC52B1056
110 changed files with 403 additions and 564 deletions

49
modules/hm/xidlehook.nix Normal file
View file

@ -0,0 +1,49 @@
{ pkgs, lib, ... }:
with lib;
let
xbacklightCmd = "${pkgs.xorg.xbacklight}/bin/xbacklight";
xsetCmd = "${pkgs.xorg.xset}/bin/xset";
lightLevel = 10;
saveLightLevel = pkgs.writeShellScript "saveLightLevel" ''
${xbacklightCmd} -get > /run/user/$UID/xbacklight_v
'';
lowerLight = pkgs.writeShellScript "lower_light" ''
${xbacklightCmd} -set ${toString lightLevel}
'';
resetLight = pkgs.writeShellScript "reset_light" ''
${xbacklightCmd} -set $(</run/user/$UID/xbacklight_v) || ${xbacklightCmd} -set 100
'';
shutDownScreens = pkgs.writeShellScript "shutdown_screens" ''
${xsetCmd} dpms force off
'';
in
{
services.xidlehook = {
enable = true;
package = pkgs.writeScriptBin "xidlehook" ''
${pkgs.xidlehook}/bin/xidlehook --detect-sleep "$@"
'';
# not-when-audio = true;
not-when-fullscreen = true;
timers = [
{
command = "${saveLightLevel} && ${lowerLight}";
canceller = "${resetLight}";
delay = 60;
}
{
command = "${pkgs.lockscreen}/bin/lockscreen";
canceller = "${resetLight}";
delay = 120;
}
{
command = "${shutDownScreens}";
canceller = "${resetLight}";
delay = 300;
}
];
};
}