1{ config, pkgs, lib, ... }:
2
3with lib;
4
5let
6 cfg = config.programs.xss-lock;
7in
8{
9 options.programs.xss-lock = {
10 enable = mkEnableOption "xss-lock";
11
12 lockerCommand = mkOption {
13 default = "${pkgs.i3lock}/bin/i3lock";
14 example = literalExample "\${pkgs.i3lock-fancy}/bin/i3lock-fancy";
15 type = types.separatedString " ";
16 description = "Locker to be used with xsslock";
17 };
18
19 extraOptions = mkOption {
20 default = [ ];
21 example = [ "--ignore-sleep" ];
22 type = types.listOf types.str;
23 description = ''
24 Additional command-line arguments to pass to
25 <command>xss-lock</command>.
26 '';
27 };
28 };
29
30 config = mkIf cfg.enable {
31 systemd.user.services.xss-lock = {
32 description = "XSS Lock Daemon";
33 wantedBy = [ "graphical-session.target" ];
34 partOf = [ "graphical-session.target" ];
35 serviceConfig.ExecStart = with lib;
36 strings.concatStringsSep " " ([
37 "${pkgs.xss-lock}/bin/xss-lock" "--session \${XDG_SESSION_ID}"
38 ] ++ (map escapeShellArg cfg.extraOptions) ++ [
39 "--"
40 cfg.lockerCommand
41 ]);
42 };
43 };
44}