2018-05-18 18:24:53 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.xss-lock;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.programs.xss-lock = {
|
2024-04-17 14:37:58 +03:00
|
|
|
enable = lib.mkEnableOption "xss-lock";
|
2019-05-11 18:56:48 +02:00
|
|
|
|
2024-04-17 14:37:58 +03:00
|
|
|
lockerCommand = lib.mkOption {
|
2019-01-04 15:41:51 +01:00
|
|
|
default = "${pkgs.i3lock}/bin/i3lock";
|
2024-04-17 14:37:58 +03:00
|
|
|
defaultText = lib.literalExpression ''"''${pkgs.i3lock}/bin/i3lock"'';
|
|
|
|
example = lib.literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"'';
|
|
|
|
type = lib.types.separatedString " ";
|
2018-05-18 18:24:53 +02:00
|
|
|
description = "Locker to be used with xsslock";
|
|
|
|
};
|
2019-05-11 18:56:48 +02:00
|
|
|
|
2024-04-17 14:37:58 +03:00
|
|
|
extraOptions = lib.mkOption {
|
2019-05-11 18:56:48 +02:00
|
|
|
default = [ ];
|
2019-05-12 03:20:44 +02:00
|
|
|
example = [ "--ignore-sleep" ];
|
2024-04-17 14:37:58 +03:00
|
|
|
type = lib.types.listOf lib.types.str;
|
2019-05-11 18:56:48 +02:00
|
|
|
description = ''
|
|
|
|
Additional command-line arguments to pass to
|
|
|
|
{command}`xss-lock`.
|
|
|
|
'';
|
|
|
|
};
|
2018-05-18 18:24:53 +02:00
|
|
|
};
|
|
|
|
|
2024-04-17 14:37:58 +03:00
|
|
|
config = lib.mkIf cfg.enable {
|
2018-05-18 18:24:53 +02:00
|
|
|
systemd.user.services.xss-lock = {
|
|
|
|
description = "XSS Lock Daemon";
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
partOf = [ "graphical-session.target" ];
|
2024-04-17 14:37:58 +03:00
|
|
|
serviceConfig.ExecStart = builtins.concatStringsSep " " (
|
|
|
|
[
|
2020-07-24 13:41:24 +02:00
|
|
|
"${pkgs.xss-lock}/bin/xss-lock"
|
|
|
|
"--session \${XDG_SESSION_ID}"
|
2024-04-17 14:37:58 +03:00
|
|
|
]
|
|
|
|
++ (builtins.map lib.escapeShellArg cfg.extraOptions)
|
|
|
|
++ [
|
2019-05-11 18:56:48 +02:00
|
|
|
"--"
|
|
|
|
cfg.lockerCommand
|
|
|
|
]
|
|
|
|
);
|
2024-04-05 11:13:38 -07:00
|
|
|
serviceConfig.Restart = "always";
|
2018-05-18 18:24:53 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|