os/modules/sway/swayidle.service.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1 KiB
Nix
Raw Permalink Normal View History

2021-05-30 19:10:28 +00:00
{
2022-11-20 22:28:23 +00:00
pkgs,
psCfg,
...
}: {
2021-05-30 19:10:28 +00:00
Unit = {
Description = "Idle manager for Wayland";
Documentation = ["man:swayidle(1)"];
BindsTo = ["graphical-session.target"];
Wants = ["graphical-session-pre.target"];
After = ["graphical-session-pre.target"];
};
Service = {
Type = "simple";
2022-10-01 21:12:48 +00:00
Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swaylock-bg}/bin:${pkgs.swayidle}/bin";
ExecStart =
'' swayidle -w \
after-resume 'swaymsg "output * dpms on"' \
2022-10-01 21:12:48 +00:00
before-sleep 'swaylock-bg' ''
+ (
if psCfg.paranoia.enable
then '' \
timeout 120 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
timeout 150 'systemctl hibernate'
''
else '' \
2022-10-01 21:12:48 +00:00
timeout 600 'swaylock-bg' \
timeout 900 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
''
);
2021-05-30 19:10:28 +00:00
};
Install = {
WantedBy = ["sway-session.target"];
};
}