pub-solar-os/modules/sway/swayidle.service.nix
Benjamin Bädorf 6d1d683b23
Fix swayidle command, add hibernation on lid close, fix env
The swayidle command in the service was straight up broken, this commit
fixes that.

Environment Variables set in the `session-variables` file are now
correctly imported across the system. This fixes `EDITOR` defaulting to
`nano`.
2022-08-25 00:13:23 +02:00

27 lines
905 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 = ''${pkgs.swayidle}/bin/swayidle -w \
after-resume 'swaymsg "output * dpms on"' \
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 '' \
timeout 600 'swaylock-bg'
timeout 900 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
'');
};
Install = {
WantedBy = [ "sway-session.target" ];
};
}