os/modules/graphical/sway/swayidle.service.nix

29 lines
805 B
Nix

{
pkgs,
psCfg,
...
}: {
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";
Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swayidle}/bin";
ExecStart = with pkgs; ''
swayidle -w \
before-sleep '${systemd}/bin/systemctl hibernate' \
timeout 120 '${swaylock-bg}/bin/swaylock-bg' \
timeout 130 '${sway}/bin/swaymsg "output * dpms off"' \
resume '${sway}/bin/swaymsg "output * dpms on"' \
timeout 300 '${systemd}/bin/systemctl hibernate'
'';
};
Install = {
WantedBy = ["sway-session.target"];
};
}