nix/modules/home-manager/desktop/sway/includes/swayidle.nix

45 lines
1.1 KiB
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 =
if cfg.swaylock.useNullPackage
then ''/usr/bin/swaylock -f''
else ''${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 ''/usr/bin/swaylock -f''
else ''${pkgs.swaylock}/bin/swaylock -f'';
}
{
event = "lock";
command =
if cfg.swaylock.useNullPackage
then ''usr/bin/swaylock -f''
else ''${pkgs.swaylock}/bin/swaylock -f'';
}
];
};
};
}