nixos-config/system/desktop/suspend.nix

28 lines
639 B
Nix
Raw Normal View History

2020-01-20 07:24:49 +01:00
{ pkgs, config, lib, ... }:
2019-10-24 02:20:38 +02:00
{
systemd.services.screenlock = {
before = [ "sleep.target" ];
requiredBy = [ "sleep.target" ];
2019-12-20 05:54:26 +01: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-16 12:20:23 +01:00
sleep 1
2019-10-24 02:20:38 +02:00
'';
serviceConfig = {
SyslogIdentifier = "screenlock";
2020-01-16 12:20:23 +01:00
#Type = "simple";
2019-10-24 02:20:38 +02:00
Type = "forking";
User = config.users.users.mainUser.name;
};
};
2020-01-20 07:24:49 +01:00
services.logind.lidSwitch = "suspend";
2019-10-24 02:20:38 +02:00
}