nixos-config/system/desktop/suspend.nix

28 lines
639 B
Nix
Raw Normal View History

2020-01-20 19:24:49 +13:00
{ pkgs, config, lib, ... }:
2019-10-24 02:20:38 +02:00
{
systemd.services.screenlock = {
before = [ "sleep.target" ];
requiredBy = [ "sleep.target" ];
2019-12-20 17:54:26 +13:00
environment = let
display = if (config.services.xserver.display != null) then
config.services.xserver.display
else
0;
in { DISPLAY = ":${toString display}"; };
2019-10-24 02:20:38 +02:00
script = ''
${pkgs.xlockmore}/bin/xlock -mode life1d -size 1 &
2020-01-17 00:20:23 +13:00
sleep 1
2019-10-24 02:20:38 +02:00
'';
serviceConfig = {
SyslogIdentifier = "screenlock";
2020-01-17 00:20:23 +13:00
#Type = "simple";
2019-10-24 02:20:38 +02:00
Type = "forking";
User = config.users.users.mainUser.name;
};
};
2020-01-20 19:24:49 +13:00
services.logind.lidSwitch = "suspend";
2019-10-24 02:20:38 +02:00
}