flakes/modules/user/hypridle.nix

46 lines
1.2 KiB
Nix
Raw Normal View History

2025-03-17 20:24:01 +11:00
{ config, lib, pkgs, ... }:
2025-03-17 15:52:18 +11:00
let
kblight = "light -s sysfs/leds/${config.me.kbBacklightDevice}";
2025-03-17 15:52:18 +11:00
in
{
2025-03-17 16:07:33 +11:00
home.packages = [ config.services.hypridle.package ];
2025-03-17 15:52:18 +11:00
services.hypridle = {
enable = true;
settings = {
general = {
lock_cmd = "pidof hyprlock || hyprlock";
2025-03-17 20:24:01 +11:00
before_sleep_cmd = "${lib.getExe pkgs.playerctl} pause; loginctl lock-session";
2025-03-17 15:52:18 +11:00
after_sleep_cmd = "hyprctl dispatch dpms on";
};
listener = lib.optionals (config.me.kbBacklightDevice != null) [
2025-03-17 15:52:18 +11:00
{
timeout = 120;
on-timeout = "${kblight} -O && ${kblight} -S 0";
on-resume = "${kblight} -I";
}
] ++ [
2025-03-17 15:52:18 +11:00
{
timeout = 150;
on-timeout = "light -O && light -T 0.5";
on-resume = "light -I";
}
{
timeout = 180;
on-timeout = "light -I && loginctl lock-session";
}
{
timeout = 195;
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
] ++ lib.optionals (config.me.environment == "laptop") [
2025-03-17 15:52:18 +11:00
{
timeout = 600;
on-timeout = "systemctl suspend";
}
];
};
};
}