tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
services.xserver.xautolock: add module
Maximilian Bosch
8 years ago
9d1db321
1321d000
+73
2 changed files
expand all
collapse all
unified
split
nixos
modules
module-list.nix
services
x11
xautolock.nix
+1
nixos/modules/module-list.nix
···
610
610
./services/x11/window-managers/windowlab.nix
611
611
./services/x11/window-managers/wmii.nix
612
612
./services/x11/window-managers/xmonad.nix
613
613
+
./services/x11/xautolock.nix
613
614
./services/x11/xbanish.nix
614
615
./services/x11/xfs.nix
615
616
./services/x11/xserver.nix
+72
nixos/modules/services/x11/xautolock.nix
···
1
1
+
{ config, lib, pkgs, ... }:
2
2
+
3
3
+
with lib;
4
4
+
5
5
+
let
6
6
+
cfg = config.services.xserver.xautolock;
7
7
+
in
8
8
+
{
9
9
+
options = {
10
10
+
services.xserver.xautolock = {
11
11
+
enable = mkEnableOption "xautolock";
12
12
+
enableNotifier = mkEnableOption "xautolock.notify" // {
13
13
+
description = ''
14
14
+
Whether to enable the notifier feature of xautolock.
15
15
+
This publishes a notification before the autolock.
16
16
+
'';
17
17
+
};
18
18
+
19
19
+
time = mkOption {
20
20
+
default = 15;
21
21
+
type = types.int;
22
22
+
23
23
+
description = ''
24
24
+
Idle time to wait until xautolock locks the computer.
25
25
+
'';
26
26
+
};
27
27
+
28
28
+
locker = mkOption {
29
29
+
default = "xlock"; # default according to `man xautolock`
30
30
+
example = "i3lock -i /path/to/img";
31
31
+
type = types.string;
32
32
+
33
33
+
description = ''
34
34
+
The script to use when locking the computer.
35
35
+
'';
36
36
+
};
37
37
+
38
38
+
notify = mkOption {
39
39
+
default = 10;
40
40
+
type = types.int;
41
41
+
42
42
+
description = ''
43
43
+
Time (in seconds) before the actual lock when the notification about the pending lock should be published.
44
44
+
'';
45
45
+
};
46
46
+
47
47
+
notifier = mkOption {
48
48
+
default = "notify-send 'Locking in 10 seconds'";
49
49
+
type = types.string;
50
50
+
51
51
+
description = ''
52
52
+
Notification script to be used to warn about the pending autolock.
53
53
+
'';
54
54
+
};
55
55
+
};
56
56
+
};
57
57
+
58
58
+
config = mkIf cfg.enable {
59
59
+
environment.systemPackages = with pkgs; [ xautolock ];
60
60
+
61
61
+
services.xserver.displayManager.sessionCommands = with builtins; with pkgs; ''
62
62
+
${xautolock}/bin/xautolock \
63
63
+
${concatStringsSep " \\\n" ([
64
64
+
"-time ${toString(cfg.time)}"
65
65
+
"-locker ${cfg.locker}"
66
66
+
] ++ optional cfg.enableNotifier (concatStringsSep " " [
67
67
+
"-notify ${toString(cfg.notify)}"
68
68
+
"-notifier \"${cfg.notifier}\""
69
69
+
]))} &
70
70
+
'';
71
71
+
};
72
72
+
}