2024-12-10 19:26:33 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2018-05-18 16:24:53 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.xss-lock;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.programs.xss-lock = {
|
2024-04-17 11:37:58 +00:00
|
|
|
enable = lib.mkEnableOption "xss-lock";
|
2019-05-11 16:56:48 +00:00
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
lockerCommand = lib.mkOption {
|
2019-01-04 14:41:51 +00:00
|
|
|
default = "${pkgs.i3lock}/bin/i3lock";
|
2024-04-17 11:37:58 +00:00
|
|
|
defaultText = lib.literalExpression ''"''${pkgs.i3lock}/bin/i3lock"'';
|
|
|
|
example = lib.literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"'';
|
|
|
|
type = lib.types.separatedString " ";
|
2018-05-18 16:24:53 +00:00
|
|
|
description = "Locker to be used with xsslock";
|
|
|
|
};
|
2019-05-11 16:56:48 +00:00
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
extraOptions = lib.mkOption {
|
2019-05-11 16:56:48 +00:00
|
|
|
default = [ ];
|
2019-05-12 01:20:44 +00:00
|
|
|
example = [ "--ignore-sleep" ];
|
2024-04-17 11:37:58 +00:00
|
|
|
type = lib.types.listOf lib.types.str;
|
2019-05-11 16:56:48 +00:00
|
|
|
description = ''
|
|
|
|
Additional command-line arguments to pass to
|
|
|
|
{command}`xss-lock`.
|
|
|
|
'';
|
|
|
|
};
|
2018-05-18 16:24:53 +00:00
|
|
|
};
|
|
|
|
|
2024-04-17 11:37:58 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2018-05-18 16:24:53 +00:00
|
|
|
systemd.user.services.xss-lock = {
|
|
|
|
description = "XSS Lock Daemon";
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
partOf = [ "graphical-session.target" ];
|
2024-12-10 19:26:33 +00:00
|
|
|
serviceConfig.ExecStart = builtins.concatStringsSep " " (
|
|
|
|
[
|
|
|
|
"${pkgs.xss-lock}/bin/xss-lock"
|
|
|
|
"--session \${XDG_SESSION_ID}"
|
|
|
|
]
|
|
|
|
++ (builtins.map lib.escapeShellArg cfg.extraOptions)
|
|
|
|
++ [
|
|
|
|
"--"
|
|
|
|
cfg.lockerCommand
|
|
|
|
]
|
|
|
|
);
|
2024-04-05 18:13:38 +00:00
|
|
|
serviceConfig.Restart = "always";
|
2018-05-18 16:24:53 +00:00
|
|
|
};
|
2024-04-27 01:30:08 +00:00
|
|
|
|
|
|
|
warnings = lib.mkIf (config.services.xserver.displayManager.startx.enable) [
|
|
|
|
"xss-lock service only works if a displayManager is set; it doesn't work when services.xserver.displayManager.startx.enable = true"
|
|
|
|
];
|
|
|
|
|
2018-05-18 16:24:53 +00:00
|
|
|
};
|
|
|
|
}
|