48 lines
1.4 KiB
Nix
48 lines
1.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
# hypridle: idle-triggered locking and display power management.
|
|
let
|
|
# The guard drops the call when a locker is already up, so no idle trigger
|
|
# stacks a second hyprlock over the first.
|
|
lockCmd = "${pkgs.procps}/bin/pidof hyprlock || ${hyprlock}";
|
|
|
|
hyprctl = "${config.programs.hyprland.package}/bin/hyprctl";
|
|
hyprlock = "${pkgs.hyprlock}/bin/hyprlock";
|
|
|
|
in
|
|
{
|
|
options.modules.desktop.session.hyprland.hypridle.enable =
|
|
lib.mkEnableOption "hypridle idle management";
|
|
|
|
config = lib.mkIf config.modules.desktop.session.hyprland.hypridle.enable {
|
|
# Closing the lid suspends, and every suspend locks first through the
|
|
# before_sleep_cmd below, so the lid always lands at a locked screen.
|
|
services.logind.settings.Login.HandleLidSwitch = "suspend";
|
|
|
|
home-manager.users.${config.user.name}.services.hypridle = {
|
|
enable = true;
|
|
|
|
settings = {
|
|
general = {
|
|
lock_cmd = lockCmd;
|
|
before_sleep_cmd = "loginctl lock-session";
|
|
# Waking pokes the compositor in case firmware leaves displays dark.
|
|
after_sleep_cmd = "${hyprctl} dispatch 'hl.dsp.dpms({ action = \"enable\" })'";
|
|
};
|
|
|
|
listener = [
|
|
# Lock on idle.
|
|
{
|
|
timeout = 300;
|
|
on-timeout = "loginctl lock-session";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|