nixos-config/components/gui/suspend.nix
Ingolf Wagner 7a6510a4e6
nix fmt
2024-08-29 08:26:04 +07:00

41 lines
901 B
Nix

{
pkgs,
config,
lib,
...
}:
with lib;
{
options.components.gui.suspend.enable = mkOption {
type = lib.types.bool;
default = config.components.gui.enable;
};
config = mkIf (config.components.gui.suspend.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;
};
};
services.logind.lidSwitch = "suspend";
};
}