pub-solar-os/modules/sway/swayidle.service.nix

30 lines
877 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";
ExecStart =
if psCfg.paranoia.enable then ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 120 'swaymsg "output * dpms off"' \
timeout 150 'systemctl hibernate' \
'' else ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 600 'swaylock-bg' \
timeout 900 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \
before-sleep 'swaylock-bg'
'';
};
Install = {
WantedBy = [ "sway-session.target" ];
};
}