Better xidlehook + screen shutdown
This commit is contained in:
parent
2b062ee946
commit
f28e934cd0
1 changed files with 24 additions and 10 deletions
|
|
@ -4,32 +4,46 @@ with lib;
|
|||
|
||||
let
|
||||
xbacklightCmd = "${pkgs.xorg.xbacklight}/bin/xbacklight";
|
||||
package = pkgs.writeScriptBin "xidlehook" ''
|
||||
${pkgs.xidlehook}/bin/xidlehook --detect-sleep "$@"
|
||||
'';
|
||||
xsetCmd = "${pkgs.xorg.xset}/bin/xset";
|
||||
lightLevel = 10;
|
||||
saveLightLevel = "${xbacklightCmd} -get > /run/user/$UID/xbacklight_v";
|
||||
lowerLight = "${xbacklightCmd} -set ${toString lightLevel}";
|
||||
resetLight =
|
||||
"${xbacklightCmd} -set $(</run/user/$UID/xbacklight_v) || ${xbacklightCmd} -set 100";
|
||||
|
||||
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 = {
|
||||
inherit package;
|
||||
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;
|
||||
canceller = "${resetLight}";
|
||||
delay = 60;
|
||||
}
|
||||
{
|
||||
command = "${pkgs.lockscreen}/bin/lockscreen";
|
||||
canceller = resetLight;
|
||||
canceller = "${resetLight}";
|
||||
delay = 120;
|
||||
}
|
||||
{
|
||||
command = "${shutDownScreens}";
|
||||
canceller = "${resetLight}";
|
||||
delay = 300;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue