System/home-manager/linux/programs/desktop/locking.nix

39 lines
1.2 KiB
Nix

{ config, lib, pkgs, ... }:
let
swaylock-package = config.nathan.config.desktop.swaylock.package;
swaylock-command = config.nathan.config.desktop.swaylock.command;
targets = config.nathan.config.desktop.targets;
hyprland = config.nathan.programs.hyprland.enable;
in lib.mkMerge [
# Hyprland specific
(lib.mkIf hyprland {
wayland.windowManager.hyprland.extraConfig = ''
bind = SUPER, Z, exec, ${swaylock-package}/bin/swaylock ${swaylock-command}
'';
})
# General
(lib.mkIf hyprland {
home.packages = with pkgs; [ swaylock-package swayidle ];
services.swayidle = {
enable = true;
timeouts = [
# Lock the screen after 5 minutes of inactivity
{
timeout = 300;
command = "${swaylock-package}/bin/swaylock ${
builtins.replaceStrings [ "%" ] [ "%%" ] swaylock-command
}";
}
# Turn off the displays after 10 minutes of inactivity
{
timeout = 600;
command = "hyprctl dispatch dpms off";
resumeCommand = "hyprctl dispatch dpms on";
}
];
};
systemd.user.services.swayidle = { Install = { WantedBy = targets; }; };
})
]