hm.nix: add chord configuration
Browse files
+63 −18 hm.nix
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | ... |
| 6 | 6 | }: let |
| 7 | 7 | inherit (lib) mkEnableOption mkOption mkIf types getExe; |
| 8 | - cfg = config.programs.oxwm; | |
| 8 | + cfg = config.programs.oxwm.settings; | |
| 9 | 9 | |
| 10 | 10 | # Converts a nix submodule into a single oxwm bar block |
| 11 | 11 | blockToLua = block: let |
| @@ -132,18 +132,54 @@ in { | ||
| 132 | 132 | }); |
| 133 | 133 | default = []; |
| 134 | 134 | description = "The list of keybinds"; |
| 135 | - example = ''[ | |
| 136 | - { | |
| 137 | - mods = [ "Mod4" "Shift" ]; | |
| 138 | - key = "Slash"; | |
| 139 | - action = "oxwm.show_keybinds()"; | |
| 140 | - } | |
| 135 | + example = '' [ | |
| 136 | + { | |
| 137 | + mods = [ "Mod4" "Shift" ]; | |
| 138 | + key = "Slash"; | |
| 139 | + action = "oxwm.show_keybinds()"; | |
| 140 | + } | |
| 141 | + { | |
| 142 | + mods = [ "Mod4" ]; | |
| 143 | + key = "D"; | |
| 144 | + action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })"; | |
| 145 | + } | |
| 146 | + ];''; | |
| 147 | + }; | |
| 148 | + chords = mkOption { | |
| 149 | + type = types.listOf (types.submodule { | |
| 150 | + options = { | |
| 151 | + notes = mkOption { | |
| 152 | + type = types.listOf (types.submodule { | |
| 153 | + options = { | |
| 154 | + mods = mkOption { | |
| 155 | + type = types.listOf types.str; | |
| 156 | + default = []; | |
| 157 | + }; | |
| 158 | + key = mkOption {type = types.str;}; | |
| 159 | + }; | |
| 160 | + }); | |
| 161 | + }; | |
| 162 | + action = mkOption {type = types.str;}; | |
| 163 | + }; | |
| 164 | + }); | |
| 165 | + default = []; | |
| 166 | + description = "A list of key chords for OXWM to use"; | |
| 167 | + example = '' [ | |
| 141 | 168 | { |
| 142 | - mods = [ "Mod4" ]; | |
| 143 | - key = "D"; | |
| 144 | - action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })"; | |
| 169 | + notes = [ | |
| 170 | + { | |
| 171 | + mods = [ "Mod4" ]; | |
| 172 | + key = "Space"; | |
| 173 | + } | |
| 174 | + { | |
| 175 | + mods = []; | |
| 176 | + key = "T"; | |
| 177 | + } | |
| 178 | + ]; | |
| 179 | + action = "oxwm.spawn_terminal()"; | |
| 145 | 180 | } |
| 146 | - ];''; | |
| 181 | + ]; | |
| 182 | + ''; | |
| 147 | 183 | }; |
| 148 | 184 | border = { |
| 149 | 185 | width = mkOption { |
| @@ -261,7 +297,7 @@ in { | ||
| 261 | 297 | }; |
| 262 | 298 | }); |
| 263 | 299 | description = "The modules to put on the bar"; |
| 264 | - example = ''[ | |
| 300 | + example = '' [ | |
| 265 | 301 | { |
| 266 | 302 | kind = "ram"; |
| 267 | 303 | interval = 5; |
| @@ -333,7 +369,7 @@ in { | ||
| 333 | 369 | }; |
| 334 | 370 | }); |
| 335 | 371 | description = "A list of window rules for the window manager to follow"; |
| 336 | - example = ''[ | |
| 372 | + example = '' [ | |
| 337 | 373 | { |
| 338 | 374 | match.class = "gimp"; |
| 339 | 375 | floating = true; |
| @@ -354,13 +390,13 @@ in { | ||
| 354 | 390 | }; |
| 355 | 391 | }; |
| 356 | 392 | |
| 357 | - config = mkIf cfg.enable { | |
| 358 | - home.packages = [cfg.package]; | |
| 393 | + config = mkIf config.programs.oxwm.enable { | |
| 394 | + home.packages = [config.programs.oxwm.package]; | |
| 359 | 395 | |
| 360 | 396 | xsession.windowManager.command = '' |
| 361 | - ${cfg.extraSessionCommands} | |
| 397 | + ${config.programs.oxwm.extraSessionCommands} | |
| 362 | 398 | export _JAVA_AWT_WM_NONREPARENTING=1 |
| 363 | - exec ${getExe cfg.package} | |
| 399 | + exec ${getExe config.programs.oxwm.package} | |
| 364 | 400 | ''; |
| 365 | 401 | |
| 366 | 402 | xdg.configFile."oxwm/config.lua".text = '' |
| @@ -402,11 +438,20 @@ in { | ||
| 402 | 438 | oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action}) |
| 403 | 439 | '') |
| 404 | 440 | cfg.binds} |
| 405 | - ${cfg.extraConfig} | |
| 441 | + ${lib.concatMapStrings (chord: '' | |
| 442 | + oxwm.key.chord({ | |
| 443 | + ${lib.concatMapStringsSep ",\n " ( | |
| 444 | + note: ''{ { ${lib.concatMapStringsSep ", " (m: ''"${m}"'') note.mods} }, "${note.key}" }'' | |
| 445 | + ) | |
| 446 | + chord.notes} | |
| 447 | + }, ${chord.action}) | |
| 448 | + '') | |
| 449 | + cfg.chords} | |
| 406 | 450 | ${lib.concatMapStrings (rule: '' |
| 407 | 451 | ${ruleToLua rule} |
| 408 | 452 | '') |
| 409 | 453 | cfg.rules} |
| 454 | + ${cfg.extraConfig} | |
| 410 | 455 | ''; |
| 411 | 456 | }; |
| 412 | 457 | } |