summaryrefslogtreecommitdiffstats
path: root/lass/3modules/screenlock.nix
blob: b5c69b65ac49830f9d46573987f3538edf8f9f5b (plain)
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
{ pkgs, config, ... }:

with import <stockholm/lib>;

let
  cfg = config.lass.screenlock;

  out = {
    options.lass.screenlock = api;
    config = mkIf cfg.enable imp;
  };

  api = {
    enable = mkEnableOption "screenlock";
    command = mkOption {
      type = types.path;
      default = pkgs.writeDash "screenlock" ''
        ${pkgs.xlockmore}/bin/xlock -mode life1d -size 1
        sleep 3
      '';
    };
  };

  imp = {
    systemd.services.screenlock = {
      before = [ "sleep.target" ];
      requiredBy = [ "sleep.target" ];
      environment = {
        DISPLAY = ":${toString config.services.xserver.display}";
      };
      serviceConfig = {
        SyslogIdentifier = "screenlock";
        ExecStart = cfg.command;
        Type = "simple";
        User = "lass";
      };
    };
  };

in out