nix/modules/home/desktop/hyprland/hypridle.nix

36 lines
1.4 KiB
Nix
Raw Normal View History

2024-03-09 17:18:36 +01:00
{ inputs, pkgs, ... }:
{
imports = [
inputs.hypridle.homeManagerModules.default
];
services.hypridle = {
enable = true;
lockCmd = "pidof ${inputs.hyprlock.packages.${pkgs.system}.hyprlock}/bin/hyprlock || ${inputs.hyprlock.packages.${pkgs.system}.hyprlock}/bin/hyprlock"; # avoid starting multiple hyprlock instances.
beforeSleepCmd = "${inputs.hyprlock.packages.${pkgs.system}.hyprlock}/bin/hyprlock"; # lock before suspend.
afterSleepCmd = "${pkgs.hyprland}/bin/hyprctl dispatch dpms on"; # to avoid having to press a key twice to turn on the display.
listeners = [
{
2024-03-12 17:31:56 +01:00
timeout = 180; # 2.5min.
2024-03-09 17:18:36 +01:00
onTimeout = "${pkgs.brightnessctl}/bin/brightnessctl -s set 10"; # set monitor backlight to minimum, avoid 0 on OLED monitor.
onResume = "${pkgs.brightnessctl}/bin/brightnessctl -r";
}
{
timeout = 300; # 5min
onTimeout = "${inputs.hyprlock.packages.${pkgs.system}.hyprlock}/bin/hyprlock";
}
{
timeout = 380; # 5.5min
onTimeout = "${pkgs.hyprland}/bin/hyprctl dispatch dpms off"; # screen off when timeout has passed
onResume = "${pkgs.hyprland}/bin/hyprctl dispatch dpms on";
}
{
timeout = 600; # 30min
onTimeout = "systemctl suspend"; # suspend pc
}
];
};
}