summary refs log tree commit diff
path: root/nixos/modules/programs/xss-lock.nix
blob: aba76133e5e338b2d54aece88e79c7910e021fd4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ config, pkgs, lib, ... }:

with lib;

let
  cfg = config.programs.xss-lock;
in
{
  options.programs.xss-lock = {
    enable = mkEnableOption "xss-lock";

    lockerCommand = mkOption {
      default = "${pkgs.i3lock}/bin/i3lock";
      defaultText = literalExpression ''"''${pkgs.i3lock}/bin/i3lock"'';
      example = literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"'';
      type = types.separatedString " ";
      description = "Locker to be used with xsslock";
    };

    extraOptions = mkOption {
      default = [ ];
      example = [ "--ignore-sleep" ];
      type = types.listOf types.str;
      description = ''
        Additional command-line arguments to pass to
        <command>xss-lock</command>.
      '';
    };
  };

  config = mkIf cfg.enable {
    systemd.user.services.xss-lock = {
      description = "XSS Lock Daemon";
      wantedBy = [ "graphical-session.target" ];
      partOf = [ "graphical-session.target" ];
      serviceConfig.ExecStart = with lib;
        strings.concatStringsSep " " ([
            "${pkgs.xss-lock}/bin/xss-lock" "--session \${XDG_SESSION_ID}"
          ] ++ (map escapeShellArg cfg.extraOptions) ++ [
            "--"
            cfg.lockerCommand
        ]);
    };
  };
}