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