nix/modules/home-manager/desktop/sway/includes/swayidle.nix
Yorick Barbanneau c1ee8f9d50
fix(sway): add possibility to not install swaylock package
Useful when using home-manager on third-party distribution. Swaylock
from nixpkgs become unable to unlock session because PAM
incompatibilities.
2025-08-27 22:25:49 +02:00

33 lines
860 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.desktop.sway;
in
{
config = mkIf config.modules.desktop.sway.enable {
services.swayidle = {
enable = true;
timeouts = [
{
timeout = 300;
command = "${pkgs.swaylock}/bin/swaylock -f";
}
{
timeout = 600;
command = ''${pkgs.sway}/bin/swaymsg "output * power off"'';
resumeCommand =''${pkgs.sway}/bin/swaymsg "output * power on"'';
}
];
events = [
{
event = "before-sleep";
command = if cfg.swaylock.useNullPackage then "swaylock" else "${pkgs.swaylock}/bin/swaylock";
}
{
event = "lock";
command = if cfg.swaylock.useNullPackage then "swaylock" else "${pkgs.swaylock}/bin/swaylock";
}
];
};
};
}