blob: 5365bf7477d02f0ced0becf05f90cbe89d88b1d9 (
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
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
|
{ name, lib, config, ... }:
with lib;
let
finalLabel =
if config.label == null then name
else config.labelPrefix + config.label;
mkDoc = anchor: "http://i3wm.org/docs/userguide.html#${anchor}";
in
{
options = {
labelPrefix = mkOption {
type = types.str;
default = "";
example = "666: ";
description = ''
The value that will be put in front of the <option>label</option>.
So if you have a label called <replaceable>bar</replaceable> and a
<option>labelPrefix</option> called <replaceable>foo</replaceable> the
label for the workspace will be <replaceable>foobar</replaceable>.
'';
};
label = mkOption {
type = types.nullOr types.str;
default = name;
description = ''
The label of this workspace, which is its name by default. If the value
is <replaceable>null</replaceable>, the resulting label of the workspace
is just its name and no <option>labelPrefix</option> is applied.
'';
};
assign = mkOption {
type = types.listOf types.attrs;
default = [];
example = [
{ class = "^Chromium(?:-browser)?\$"; }
{ instance = "^gajim\$"; }
];
description = let
anchor = "_automatically_putting_clients_on_specific_workspaces";
in ''
Assign windows to this specific workspace using the attribute names
described by <link xlink:href="${mkDoc anchor}"/>.
'';
};
head = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
The XRandR head this workspace will be assigned to.
'';
};
keys = let
commonDesc = ''
The <replaceable>$mod</replaceable> placeholder represents the default
modifier key. Details about the syntax of key combinations can be found
at <link xlink:href="${mkDoc "keybindings"}"/>.
'';
in {
switchTo = mkOption {
type = types.nullOr types.str;
default = null;
example = "$mod+1";
description = ''
Key combination to switch to this workspace.
'' + commonDesc;
};
moveTo = mkOption {
type = types.nullOr types.str;
default = null;
example = "$mod+Shift+exclam";
description = ''
Key combination to move a container to this workspace.
'' + commonDesc;
};
};
config = mkOption {
type = types.lines;
default = "";
description = ''
Raw configuration options for this workspace.
'';
};
};
config.config = let
maybeOutput = optionalString (config.head != null) " output ${config.head}";
mkAssign = mapAttrsToList (criteria: value: "${criteria}=\"${value}\"");
mkSym = sym: rest: optionalString (sym != null) "bindsym ${sym} ${rest}";
in ''
workspace "${finalLabel}"${maybeOutput}
${mkSym config.keys.switchTo "workspace \"${finalLabel}\""}
${mkSym config.keys.moveTo "move workspace \"${finalLabel}\""}
${concatMapStrings (assign: ''
assign [${concatStringsSep " " (mkAssign assign)}] ${finalLabel}
'') config.assign}
'';
}
|