tony / oxwm

Merge remote-tracking branch 'origin/master' Browse files
tonybanters committed 2026-02-18 parents 718b4b5 241576b commit e9c4933199e069999187c8119b8013a4623f094c
Showing 1 changed file with 91 additions and 76 deletions. UnifiedSplit
+91 −76 hm.nix
@@ -5,6 +5,7 @@
5 5 ...
6 6 }: let
7 7 inherit (lib) mkEnableOption mkOption mkIf types concatMapStringsSep concatStringsSep concatMapStrings boolToString optional;
8 + inherit (lib.strings) escapeNixString;
8 9 cfg = config.programs.oxwm.settings;
9 10
10 11 # Converts a nix submodule into a single oxwm bar block
@@ -12,7 +13,8 @@
12 13 common = ''
13 14 interval = ${toString block.interval},
14 15 color = "#${block.color}",
15 - underline = ${boolToString block.underline},'';
16 + underline = ${boolToString block.underline},
17 + '';
16 18 in
17 19 "oxwm.bar.block.${block.kind}({\n"
18 20 + (
@@ -133,18 +135,20 @@ in {
133 135 });
134 136 default = [];
135 137 description = "The list of keybinds";
136 - example = '' [
137 - {
138 - mods = [ "Mod4" "Shift" ];
139 - key = "Slash";
140 - action = "oxwm.show_keybinds()";
141 - }
142 - {
143 - mods = [ "Mod4" ];
144 - key = "D";
145 - action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })";
146 - }
147 - ];'';
138 + example = ''
139 + [
140 + {
141 + mods = [ "Mod4" "Shift" ];
142 + key = "Slash";
143 + action = "oxwm.show_keybinds()";
144 + }
145 + {
146 + mods = [ "Mod4" ];
147 + key = "D";
148 + action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })";
149 + }
150 + ];
151 + '';
148 152 };
149 153 chords = mkOption {
150 154 type = types.listOf (types.submodule {
@@ -165,21 +169,22 @@ in {
165 169 });
166 170 default = [];
167 171 description = "A list of key chords for OXWM to use";
168 - example = '' [
169 - {
170 - notes = [
171 - {
172 - mods = [ "Mod4" ];
173 - key = "Space";
174 - }
175 - {
176 - mods = [];
177 - key = "T";
178 - }
179 - ];
180 - action = "oxwm.spawn_terminal()";
181 - }
182 - ];
172 + example = ''
173 + [
174 + {
175 + notes = [
176 + {
177 + mods = [ "Mod4" ];
178 + key = "Space";
179 + }
180 + {
181 + mods = [];
182 + key = "T";
183 + }
184 + ];
185 + action = "oxwm.spawn_terminal()";
186 + }
187 + ];
183 188 '';
184 189 };
185 190 border = {
@@ -298,28 +303,30 @@ in {
298 303 };
299 304 });
300 305 description = "The modules to put on the bar";
301 - example = '' [
302 - {
303 - kind = "ram";
304 - interval = 5;
305 - format = "Ram: {used}/{total} GB";
306 - color = "9ece6a";
307 - }
308 - {
309 - kind = "static";
310 - text = "|";
311 - interval = 99999999;
312 - color = "6dade3";
313 - }
314 - {
315 - kind = "shell";
316 - format = "{}";
317 - command = "uname -r";
318 - interval = 9999999;
319 - color = "f7768e";
320 - underline = true;
321 - }
322 - ];'';
306 + example = ''
307 + [
308 + {
309 + kind = "ram";
310 + interval = 5;
311 + format = "Ram: {used}/{total} GB";
312 + color = "9ece6a";
313 + }
314 + {
315 + kind = "static";
316 + text = "|";
317 + interval = 99999999;
318 + color = "6dade3";
319 + }
320 + {
321 + kind = "shell";
322 + format = "{}";
323 + command = "uname -r";
324 + interval = 9999999;
325 + color = "f7768e";
326 + underline = true;
327 + }
328 + ];
329 + '';
323 330 };
324 331 };
325 332 rules = mkOption {
@@ -370,18 +377,20 @@ in {
370 377 };
371 378 });
372 379 description = "A list of window rules for the window manager to follow";
373 - example = '' [
374 - {
375 - match.class = "gimp";
376 - floating = true;
377 - }
378 - {
379 - match.class = "firefox";
380 - match.title = "Library";
381 - tag = 9;
382 - focus = true;
383 - }
384 - ];'';
380 + example = ''
381 + [
382 + {
383 + match.class = "gimp";
384 + floating = true;
385 + }
386 + {
387 + match.class = "firefox";
388 + match.title = "Library";
389 + tag = 9;
390 + focus = true;
391 + }
392 + ];
393 + '';
385 394 };
386 395 extraConfig = mkOption {
387 396 type = types.lines;
@@ -398,7 +407,7 @@ in {
398 407
399 408 oxwm.set_terminal("${cfg.terminal}")
400 409 oxwm.set_modkey("${cfg.modkey}")
401 - oxwm.set_tags({${concatMapStringsSep ", " (t: ''"${t}"'') cfg.tags}})
410 + oxwm.set_tags({${concatMapStringsSep ", " escapeNixString cfg.tags}})
402 411
403 412 local blocks = {
404 413 ${concatMapStringsSep ",\n" blockToLua cfg.bar.blocks}
@@ -423,27 +432,33 @@ in {
423 432 oxwm.set_layout_symbol("normie", "${cfg.layoutSymbol.normie}")
424 433 oxwm.set_layout_symbol("tabbed", "${cfg.layoutSymbol.tabbed}")
425 434
426 - ${concatMapStrings (cmd: ''
435 + ${
436 + concatMapStrings (cmd: ''
427 437 oxwm.autostart("${cmd}")
428 438 '')
429 - cfg.autostart}
430 - ${concatMapStrings (bind: ''
431 - oxwm.key.bind({ ${concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action})
439 + cfg.autostart
440 + }
441 + ${
442 + concatMapStrings (bind: ''
443 + oxwm.key.bind({ ${concatMapStringsSep ", " escapeNixString bind.mods} }, "${bind.key}", ${bind.action})
432 444 '')
433 - cfg.binds}
434 - ${concatMapStrings (chord: ''
445 + cfg.binds
446 + }
447 + ${
448 + concatMapStrings (chord: ''
435 449 oxwm.key.chord({
436 - ${concatMapStringsSep ",\n " (
437 - note: ''{ { ${concatMapStringsSep ", " (m: ''"${m}"'') note.mods} }, "${note.key}" }''
438 - )
439 - chord.notes}
450 + ${concatMapStringsSep ",\n " (note: ''{ { ${concatMapStringsSep ", " escapeNixString note.mods} }, "${note.key}" }'') chord.notes}
440 451 }, ${chord.action})
441 452 '')
442 - cfg.chords}
443 - ${concatMapStrings (rule: ''
453 + cfg.chords
454 + }
455 + ${
456 + concatMapStrings (rule: ''
444 457 ${ruleToLua rule}
445 458 '')
446 - cfg.rules}
459 + cfg.rules
460 + }
461 +
447 462 ${cfg.extraConfig}
448 463 '';
449 464 };