tony / oxwm

hm.nix: add descriptions and examples Browse files
Pascal0577 committed 2026-02-18 parent 9c4b212 commit 736f91b76443e55820da708f204cde33710b5ad8
Showing 1 changed file with 333 additions and 121 deletions. UnifiedSplit
+333 −121 hm.nix
@@ -1,5 +1,9 @@
1 -{ self }: { config, lib, pkgs, ... }: 1 +{self}: {
2 -let 2 + config,
3 + lib,
4 + pkgs,
5 + ...
6 +}: let
3 inherit (lib) mkEnableOption mkOption mkIf types getExe; 7 inherit (lib) mkEnableOption mkOption mkIf types getExe;
4 cfg = config.programs.oxwm; 8 cfg = config.programs.oxwm;
5 9
@@ -9,42 +13,54 @@ let
9 interval = ${toString block.interval}, 13 interval = ${toString block.interval},
10 color = "#${block.color}", 14 color = "#${block.color}",
11 underline = ${lib.boolToString block.underline},''; 15 underline = ${lib.boolToString block.underline},'';
12 - in "oxwm.bar.block.${block.kind}({\n" + 16 + in
13 - (if block.kind == "static" then '' 17 + "oxwm.bar.block.${block.kind}({\n"
14 - text = "${block.text}", 18 + + (
15 - ${common} 19 + if block.kind == "static"
16 - '' else if block.kind == "shell" then '' 20 + then ''
17 - format = "${block.format}", 21 + text = "${block.text}",
18 - command = "${block.command}", 22 + ${common}
19 - ${common} 23 + ''
20 - '' else if block.kind == "datetime" then '' 24 + else if block.kind == "shell"
21 - format = "${block.format}", 25 + then ''
22 - date_format = "${block.date_format}", 26 + format = "${block.format}",
23 - ${common} 27 + command = "${block.command}",
24 - '' else if block.kind == "battery" then '' 28 + ${common}
25 - format = "${block.format}", 29 + ''
26 - charging = "${block.charging}", 30 + else if block.kind == "datetime"
27 - discharging = "${block.discharging}", 31 + then ''
28 - full = "${block.full}", 32 + format = "${block.format}",
29 - ${common} 33 + date_format = "${block.date_format}",
30 - '' else '' 34 + ${common}
31 - format = "${block.format}", 35 + ''
32 - ${common} 36 + else if block.kind == "battery"
33 - '') + "})"; 37 + then ''
38 + format = "${block.format}",
39 + charging = "${block.charging}",
40 + discharging = "${block.discharging}",
41 + full = "${block.full}",
42 + ${common}
43 + ''
44 + else ''
45 + format = "${block.format}",
46 + ${common}
47 + ''
48 + )
49 + + "})";
34 50
35 - ruleToLua = rule: let 51 + ruleToLua = rule: let
36 - fields = lib.concatStringsSep ", " ( 52 + fields = lib.concatStringsSep ", " (
37 - lib.optional (rule.match.class != null) ''class = "${rule.match.class}"'' ++ 53 + lib.optional (rule.match.class != null) ''class = "${rule.match.class}"''
38 - lib.optional (rule.match.instance != null) ''instance = "${rule.match.instance}"'' ++ 54 + ++ lib.optional (rule.match.instance != null) ''instance = "${rule.match.instance}"''
39 - lib.optional (rule.match.title != null) ''title = "${rule.match.title}"'' ++ 55 + ++ lib.optional (rule.match.title != null) ''title = "${rule.match.title}"''
40 - lib.optional (rule.match.role != null) ''role = "${rule.match.role}"'' ++ 56 + ++ lib.optional (rule.match.role != null) ''role = "${rule.match.role}"''
41 - lib.optional (rule.floating != null) ''floating = ${lib.boolToString rule.floating}'' ++ 57 + ++ lib.optional (rule.floating != null) ''floating = ${lib.boolToString rule.floating}''
42 - lib.optional (rule.tag != null) ''tag = ${toString rule.tag}'' ++ 58 + ++ lib.optional (rule.tag != null) ''tag = ${toString rule.tag}''
43 - lib.optional (rule.fullscreen != null) ''fullscreen = ${lib.boolToString rule.fullscreen}'' 59 + ++ lib.optional (rule.fullscreen != null) ''fullscreen = ${lib.boolToString rule.fullscreen}''
44 - ); 60 + ++ lib.optional (rule.focus != null) ''focus = ${lib.boolToString rule.fullscreen}''
45 - in "oxwm.rule.add({ ${fields} })"; 61 + );
46 -in 62 + in "oxwm.rule.add({ ${fields} })";
47 -{ 63 +in {
48 options.programs.oxwm = { 64 options.programs.oxwm = {
49 enable = mkEnableOption "oxwm window manager"; 65 enable = mkEnableOption "oxwm window manager";
50 package = mkOption { 66 package = mkOption {
@@ -57,96 +73,289 @@ in
57 default = ""; 73 default = "";
58 description = "Shell commands executed just before oxwm is started"; 74 description = "Shell commands executed just before oxwm is started";
59 }; 75 };
60 - terminal = mkOption { type = types.str; default = "alacritty"; }; 76 + settings = {
61 - modkey = mkOption { type = types.str; default = "Mod4"; }; 77 + terminal = mkOption {
62 - tags = mkOption { type = types.listOf types.str; 78 + type = types.str;
63 - default = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" ]; 79 + default = "alacritty";
64 - }; 80 + description = "Terminal used";
65 - layoutSymbol = {
66 - tiling = mkOption { type = types.str; default = "[T]"; };
67 - normie = mkOption { type = types.str; default = "[F]"; };
68 - tabbed = mkOption { type = types.str; default = "[=]"; };
69 - };
70 - autostart = mkOption {
71 - type = types.listOf types.str;
72 - default = [];
73 - };
74 - binds = mkOption {
75 - type = types.listOf (types.submodule {
76 - options = {
77 - mods = mkOption { type = types.listOf types.str; default = [ "${cfg.modkey}" ]; };
78 - key = mkOption { type = types.str; };
79 - action = mkOption { type = types.str; };
80 - };
81 - });
82 - default = [];
83 - };
84 - border = {
85 - width = mkOption { type = types.int; default = 2; };
86 - focusedColor = mkOption { type = types.str; default = "6dade3"; };
87 - unfocusedColor = mkOption { type = types.str; default = "bbbbbb"; };
88 - };
89 - gaps = {
90 - smart = mkOption { type = types.enum [ "enabled" "disabled" ]; default = "enabled"; };
91 - inner = mkOption { type = types.listOf types.int; default = [ 5 5 ];};
92 - outer = mkOption { type = types.listOf types.int; default = [ 5 5 ];};
93 - };
94 - bar = {
95 - font = mkOption { type = types.str; default = "monospace 10"; };
96 - hideVacantTags = mkOption { type = types.bool; default = false; };
97 - unoccupiedScheme = mkOption {
98 - type = types.listOf types.str;
99 - default = [ "bbbbbb" "1a1b26" "444444" ];
100 }; 81 };
101 - occupiedScheme = mkOption { 82 + modkey = mkOption {
102 - type = types.listOf types.str; 83 + type = types.str;
103 - default = [ "0db9d7" "1a1b26" "0db9d7" ]; 84 + default = "Mod4";
85 + description = "Modifier key. Used for mouse dragging";
104 }; 86 };
105 - selectedScheme = mkOption { 87 + tags = mkOption {
106 type = types.listOf types.str; 88 type = types.listOf types.str;
107 - default = [ "0db9d7" "1a1b26" "ad8ee6" ]; 89 + default = ["1" "2" "3" "4" "5" "6" "7" "8" "9"];
90 + description = "Workspace tags";
91 + example = ["" "󰊯" "" "" "󰙯" "󱇤" "" "󱘶" "󰧮"];
108 }; 92 };
109 - urgentScheme = mkOption { 93 + layoutSymbol = {
94 + tiling = mkOption {
95 + type = types.str;
96 + default = "[T]";
97 + description = "Symbol in tiling mode";
98 + };
99 + normie = mkOption {
100 + type = types.str;
101 + default = "[F]";
102 + description = "Symbol in normie mode";
103 + };
104 + tabbed = mkOption {
105 + type = types.str;
106 + default = "[=]";
107 + description = "Symbol in tabbed mode";
108 + };
109 + };
110 + autostart = mkOption {
110 type = types.listOf types.str; 111 type = types.listOf types.str;
111 - default = [ "f7768e" "1a1b26" "f7768e" ]; 112 + default = [];
113 + description = "A list of commands to run when oxwm starts";
112 }; 114 };
113 - blocks = mkOption { type = types.listOf (types.submodule { 115 + binds = mkOption {
114 - options = { 116 + type = types.listOf (types.submodule {
115 - kind = mkOption { 117 + options = {
116 - type = types.enum [ "ram" "static" "shell" "datetime" "battery" ]; 118 + mods = mkOption {
117 - default = "static"; 119 + type = types.listOf types.str;
120 + default = ["${cfg.modkey}"];
121 + description = "The modifier keys to invoke the command";
122 + };
123 + key = mkOption {
124 + type = types.str;
125 + description = "The keystroke to invoke the command";
126 + };
127 + action = mkOption {
128 + type = types.str;
129 + description = "The command to invoke";
130 + };
118 }; 131 };
119 - interval = mkOption { type = types.int; default = 5; }; 132 + });
120 - color = mkOption { type = types.str; default = ""; }; 133 + default = [];
121 - underline = mkOption { type = types.bool; default = true; }; 134 + description = "The list of keybinds";
122 - text = mkOption { type = types.str; default = "|"; }; 135 + example = ''[
123 - format = mkOption { type = types.str; default = "{}"; }; 136 + {
124 - command = mkOption { type = types.str; default = "uname -r"; }; 137 + mods = [ "Mod4" "Shift" ];
125 - date_format = mkOption { type = types.str; default = "%a, %b %d - %-I:%M %P"; }; 138 + key = "Slash";
126 - charging = mkOption { type = types.str; default = "⚡ Bat: {}%"; }; 139 + action = "oxwm.show_keybinds()";
127 - discharging = mkOption { type = types.str; default = "- Bat: {}%"; }; 140 + }
128 - full = mkOption { type = types.str; default = "✓ Bat: {}%"; }; 141 + {
129 - }; 142 + mods = [ "Mod4" ];
130 - }); }; 143 + key = "D";
131 - }; 144 + action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })";
132 - rules = mkOption { type = types.listOf (types.submodule { 145 + }
133 - options = { 146 + ];'';
134 - match = { 147 + };
135 - class = mkOption { type = types.nullOr types.str; default = null; }; 148 + border = {
136 - instance = mkOption { type = types.nullOr types.str; default = null; }; 149 + width = mkOption {
137 - title = mkOption { type = types.nullOr types.str; default = null; }; 150 + type = types.int;
138 - role = mkOption { type = types.nullOr types.str; default = null; }; 151 + default = 2;
139 - }; 152 + description = "Width of the window borders";
140 - floating = mkOption { type = types.nullOr types.bool; default = null; }; 153 + };
141 - tag = mkOption { type = types.nullOr types.int; default = null; }; 154 + focusedColor = mkOption {
142 - fullscreen = mkOption { type = types.nullOr types.bool; default = null; }; 155 + type = types.str;
156 + default = "6dade3";
157 + description = "Color of the focused window";
158 + };
159 + unfocusedColor = mkOption {
160 + type = types.str;
161 + default = "bbbbbb";
162 + description = "Color of the unfocused window";
163 + };
143 }; 164 };
144 - }); }; 165 + gaps = {
145 - extraConfig = mkOption { type = types.lines; default = ""; }; 166 + smart = mkOption {
167 + type = types.enum ["enabled" "disabled"];
168 + default = "enabled";
169 + description = "If enabled, removes border if single window in tag";
170 + };
171 + inner = mkOption {
172 + type = types.listOf types.int;
173 + default = [5 5];
174 + description = "Inner gaps [ horizontal vertical ] in pixels";
175 + };
176 + outer = mkOption {
177 + type = types.listOf types.int;
178 + default = [5 5];
179 + description = "Outer gaps [ horizontal vertical ] in pixels";
180 + };
181 + };
182 + bar = {
183 + font = mkOption {
184 + type = types.str;
185 + default = "monospace 10";
186 + description = "The font displayed on the bar";
187 + };
188 + hideVacantTags = mkOption {
189 + type = types.bool;
190 + default = false;
191 + description = "Whether to hide tags with no windows from the bar";
192 + };
193 + unoccupiedScheme = mkOption {
194 + type = types.listOf types.str;
195 + default = ["bbbbbb" "1a1b26" "444444"];
196 + description = "The colorscheme to use for unoccupied tags as hex colors. Do not put a `#` before each color.";
197 + };
198 + occupiedScheme = mkOption {
199 + type = types.listOf types.str;
200 + default = ["0db9d7" "1a1b26" "0db9d7"];
201 + description = "The colorscheme to use for occupied tags as hex colors. Do not put a `#` before each color.";
202 + };
203 + selectedScheme = mkOption {
204 + type = types.listOf types.str;
205 + default = ["0db9d7" "1a1b26" "ad8ee6"];
206 + description = "The colorscheme to use for selected tags as hex colors. Do not put a `#` before each color.";
207 + };
208 + urgentScheme = mkOption {
209 + type = types.listOf types.str;
210 + default = ["f7768e" "1a1b26" "f7768e"];
211 + description = "The colorscheme to use for tags with a window requesting attention as hex colors. Do not put a `#` before each color.";
212 + };
213 + blocks = mkOption {
214 + type = types.listOf (types.submodule {
215 + options = {
216 + kind = mkOption {
217 + type = types.enum ["ram" "static" "shell" "datetime" "battery"];
218 + default = "static";
219 + description = "The kind of block to be used";
220 + };
221 + interval = mkOption {
222 + type = types.int;
223 + default = 5;
224 + };
225 + color = mkOption {
226 + type = types.str;
227 + default = "";
228 + };
229 + underline = mkOption {
230 + type = types.bool;
231 + default = true;
232 + };
233 + text = mkOption {
234 + type = types.str;
235 + default = "|";
236 + };
237 + format = mkOption {
238 + type = types.str;
239 + default = "{}";
240 + };
241 + command = mkOption {
242 + type = types.str;
243 + default = "uname -r";
244 + };
245 + date_format = mkOption {
246 + type = types.str;
247 + default = "%a, %b %d - %-I:%M %P";
248 + };
249 + charging = mkOption {
250 + type = types.str;
251 + default = "⚡ Bat: {}%";
252 + };
253 + discharging = mkOption {
254 + type = types.str;
255 + default = "- Bat: {}%";
256 + };
257 + full = mkOption {
258 + type = types.str;
259 + default = "✓ Bat: {}%";
260 + };
261 + };
262 + });
263 + description = "The modules to put on the bar";
264 + example = ''[
265 + {
266 + kind = "ram";
267 + interval = 5;
268 + format = "Ram: {used}/{total} GB";
269 + color = "9ece6a";
270 + }
271 + {
272 + kind = "static";
273 + text = "|";
274 + interval = 99999999;
275 + color = "6dade3";
276 + }
277 + {
278 + kind = "shell";
279 + format = "{}";
280 + command = "uname -r";
281 + interval = 9999999;
282 + color = "f7768e";
283 + underline = true;
284 + }
285 + ];'';
286 + };
287 + };
288 + rules = mkOption {
289 + type = types.listOf (types.submodule {
290 + options = {
291 + match = {
292 + class = mkOption {
293 + type = types.nullOr types.str;
294 + default = null;
295 + description = "The class to match windows with";
296 + };
297 + instance = mkOption {
298 + type = types.nullOr types.str;
299 + default = null;
300 + description = "The instance to match windows with";
301 + };
302 + title = mkOption {
303 + type = types.nullOr types.str;
304 + default = null;
305 + description = "The title to match windows with";
306 + };
307 + role = mkOption {
308 + type = types.nullOr types.str;
309 + default = null;
310 + description = "The role to match windows with";
311 + };
312 + };
313 + floating = mkOption {
314 + type = types.nullOr types.bool;
315 + default = null;
316 + description = "Whether to apply floating to the matched window";
317 + };
318 + tag = mkOption {
319 + type = types.nullOr types.int;
320 + default = null;
321 + description = "What tag the matched window should be opened on";
322 + };
323 + fullscreen = mkOption {
324 + type = types.nullOr types.bool;
325 + default = null;
326 + description = "Whether to apply fullscreen to the matched window";
327 + };
328 + focus = mkOption {
329 + type = types.nullOr types.bool;
330 + default = null;
331 + description = "Whether to apply focus to the matched window";
332 + };
333 + };
334 + });
335 + description = "A list of window rules for the window manager to follow";
336 + example = ''[
337 + {
338 + match.class = "gimp";
339 + floating = true;
340 + }
341 + {
342 + match.class = "firefox";
343 + match.title = "Library";
344 + tag = 9;
345 + focus = true;
346 + }
347 + ];'';
348 + };
349 + extraConfig = mkOption {
350 + type = types.lines;
351 + default = "";
352 + description = "Extra lua confguration that gets inserted at the bottom of the file";
353 + };
354 + };
146 }; 355 };
147 356
148 config = mkIf cfg.enable { 357 config = mkIf cfg.enable {
149 - home.packages = [ cfg.package ]; 358 + home.packages = [cfg.package];
150 359
151 xsession.windowManager.command = '' 360 xsession.windowManager.command = ''
152 ${cfg.extraSessionCommands} 361 ${cfg.extraSessionCommands}
@@ -187,14 +396,17 @@ in
187 396
188 ${lib.concatMapStrings (cmd: '' 397 ${lib.concatMapStrings (cmd: ''
189 oxwm.autostart("${cmd}") 398 oxwm.autostart("${cmd}")
190 - '') cfg.autostart} 399 + '')
400 + cfg.autostart}
191 ${lib.concatMapStrings (bind: '' 401 ${lib.concatMapStrings (bind: ''
192 - oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action}) 402 + oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action})
193 - '') cfg.binds} 403 + '')
404 + cfg.binds}
194 ${cfg.extraConfig} 405 ${cfg.extraConfig}
195 ${lib.concatMapStrings (rule: '' 406 ${lib.concatMapStrings (rule: ''
196 - ${ruleToLua rule} 407 + ${ruleToLua rule}
197 - '') cfg.rules} 408 + '')
409 + cfg.rules}
198 ''; 410 '';
199 }; 411 };
200 } 412 }