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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{ tgcMaintainers, ... }:
{
config,
pkgs,
lib,
...
}:
let
inherit (lib) types;
cfg = config.tgc.programs.gtklock;
configFormat = pkgs.formats.ini {
listToValue = builtins.concatStringsSep ";";
};
configFile = configFormat.generate "gtklock-config.ini" cfg.settings;
in
{
meta.maintainers = [ tgcMaintainers.zaphyra ];
options.tgc.programs.gtklock = {
enable = lib.mkEnableOption "gtklock, a GTK-based lockscreen for Wayland";
package = lib.mkPackageOption pkgs "gtklock" { };
systemd.enable = lib.mkEnableOption "Enable systemd user service (can be used with e.g. systemd-lock-handler)";
settings = lib.mkOption {
type = configFormat.type;
example = lib.literalExpression ''
{
main = {
idle-hide = true;
idle-timeout = 10;
};
}'';
description = ''
Configuration for gtklock.
See [`gtklock(1)`](https://github.com/jovanlanik/gtklock/blob/master/man/gtklock.1.scd) man page for details.
'';
};
style = lib.mkOption {
type = with types; nullOr str;
default = null;
description = ''
CSS Stylesheet for gtklock.
See [gtklock's wiki](https://github.com/jovanlanik/gtklock/wiki#Styling) for details.
'';
};
modules = lib.mkOption {
type = with types; listOf package;
default = [ ];
example = lib.literalExpression ''
with pkgs; [
gtklock-playerctl-module
gtklock-powerbar-module
gtklock-userinfo-module
]'';
description = "gtklock modules to load.";
};
};
config = lib.mkIf cfg.enable {
tgc.programs.gtklock.settings.main = {
style = lib.mkIf (cfg.style != null) "${pkgs.writeText "style.css" cfg.style}";
modules = lib.mkIf (cfg.modules != [ ]) (
map (pkg: "${pkg}/lib/gtklock/${lib.removePrefix "gtklock-" pkg.pname}.so") cfg.modules
);
};
xdg.configFile."gtklock/config.ini" = lib.mkIf (cfg.settings != { }) { source = configFile; };
home.packages = [ cfg.package ];
systemd.user.services.gtklock = lib.mkIf cfg.systemd.enable {
Unit = {
Description = "GTK-based lockscreen for Wayland";
Documentation = "https://github.com/jovanlanik/gtklock";
OnSuccess = [ "unlock.target" ];
PartOf = [ "lock.target" ];
After = [ "lock.target" ];
};
Service = {
ExecStart = lib.getExe cfg.package;
Restart = "on-failure";
RestartSec = 0;
};
Install.WantedBy = [ "lock.target" ];
};
};
}