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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
{
config,
lib,
pkgs,
...
}: let
inherit (lib) maintainers mkEnableOption mkIf mkPackageOption mkOption types;
cfg = config.services.jankyborders;
joinStrings = strings: builtins.concatStringsSep "," strings;
optionalArg = arg: value:
if value != null && value != ""
then
if lib.isList value
then lib.map (val: "${arg}=${val}") value
else ["${arg}=${value}"]
else [];
in {
meta.maintainers = [
maintainers.amsynist or "amsynist"
];
options.services.jankyborders = {
enable = mkEnableOption "Enable the jankyborders service.";
package = mkPackageOption pkgs "jankyborders" {};
width = mkOption {
type = types.float;
default = 5.0;
description = ''
Determines the width of the border. For example, width=5.0 creates a border 5.0 points wide.
'';
};
hidpi = mkOption {
type = types.bool;
default = false;
description = ''
If set to on, the border will be drawn with retina resolution.
'';
};
active_color = mkOption {
type = types.str;
default = "0xFFFFFFFF";
example = "0xFFFFFFFF";
description = ''
Sets the border color for the focused window (format: 0xAARRGGBB). For instance, active_color="0xff00ff00" creates a green border.
For Gradient Border : active_color="gradient(top_right=0x9992B3F5,bottom_left=0x9992B3F5)"
'';
};
inactive_color = mkOption {
type = types.str;
default = "0xFFFFFFFF";
example = "0xFFFFFFFF";
description = ''
Sets the border color for all windows not in focus (format: 0xAARRGGBB).
For Gradient Border : inactive_color="gradient(top_right=0x9992B3F5,bottom_left=0x9992B3F5)"
'';
};
background_color = mkOption {
type = types.str;
default = "";
example = "0xFFFFFFFF";
description = ''
Sets the background fill color for all windows (only 0xAARRGGBB arguments supported).
'';
};
style = mkOption {
type = types.str;
default = "round";
example = "square/round";
description = ''
Specifies the style of the border (either round or square).
'';
};
order = mkOption {
type = types.enum [ "above" "below" ];
default = "below";
example = "above";
description = ''
Specifies whether borders should be drawn above or below windows.
'';
};
blur_radius = mkOption {
type = types.float;
default = 0.0;
example = 5.0;
description = ''
Sets the blur radius applied to the borders or backgrounds with transparency.
'';
};
ax_focus = mkOption {
type = types.bool;
default = false;
description = ''
If set to true, the (slower) accessibility API is used to resolve the focused window.
'';
};
blacklist = mkOption {
type = types.listOf types.str;
default = [];
example = ["Safari" "kitty"];
description = ''
The applications specified here are excluded from being bordered.
For example, blacklist = [ "Safari" "kitty" ] excludes Safari and kitty from being bordered.
'';
};
whitelist = mkOption {
type = types.listOf types.str;
default = [];
example = ["Arc" "USB Overdrive"];
description = ''
Once this list is populated, only applications listed here are considered for receiving a border.
If the whitelist is empty (default) it is inactive.
'';
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = !(cfg.blacklist != [] && cfg.whitelist != []);
message = "Cannot define both a blacklist and a whitelist for jankyborders.";
}
];
environment.systemPackages = [cfg.package];
launchd.user.agents.jankyborders = {
serviceConfig.ProgramArguments =
[
"${cfg.package}/bin/borders"
]
++ (optionalArg "width" (toString cfg.width))
++ (optionalArg "hidpi" (
if cfg.hidpi
then "on"
else "off"
))
++ (optionalArg "active_color" cfg.active_color)
++ (optionalArg "inactive_color" cfg.inactive_color)
++ (optionalArg "background_color" cfg.background_color)
++ (optionalArg "style" cfg.style)
++ (optionalArg "blur_radius" (toString cfg.blur_radius))
++ (optionalArg "ax_focus" (
if cfg.ax_focus
then "on"
else "off"
))
++ (optionalArg "blacklist" (joinStrings cfg.blacklist))
++ (optionalArg "whitelist" (joinStrings cfg.whitelist))
++ (optionalArg "order" cfg.order);
serviceConfig.KeepAlive = true;
serviceConfig.RunAtLoad = true;
};
};
}
|