nixos-config/nixos/system/desktop/suspend.nix

38 lines
854 B
Nix
Raw Normal View History

2020-01-20 07:24:49 +01:00
{ pkgs, config, lib, ... }:
2021-03-05 17:42:00 +01:00
with lib;
2019-10-24 02:20:38 +02:00
2021-03-05 17:42:00 +01:00
let
cfg = config.system.custom.suspend;
in {
options.system.custom.suspend.enable = mkEnableOption "use xlock in suspend";
config = mkIf cfg.enable {
systemd.services.screenlock = {
before = [ "sleep.target" ];
requiredBy = [ "sleep.target" ];
environment = let
display = if (config.services.xserver.display != null) then
config.services.xserver.display
else
0;
in { DISPLAY = ":${toString display}"; };
script = ''
${pkgs.xlockmore}/bin/xlock -mode life1d -size 1 &
sleep 1
'';
serviceConfig = {
SyslogIdentifier = "screenlock";
#Type = "simple";
Type = "forking";
User = config.users.users.mainUser.name;
};
2019-10-24 02:20:38 +02:00
};
2021-03-05 17:42:00 +01:00
services.logind.lidSwitch = "suspend";
2019-10-24 02:20:38 +02:00
2021-03-05 17:42:00 +01:00
};
2019-10-24 02:20:38 +02:00
}