hm.nix: add chord configuration
Browse files
+63 −18 hm.nix
| @@ -5,7 +5,7 @@ | |||
| 5 | ... | 5 | ... |
| 6 | }: let | 6 | }: let |
| 7 | inherit (lib) mkEnableOption mkOption mkIf types getExe; | 7 | inherit (lib) mkEnableOption mkOption mkIf types getExe; |
| 8 | - cfg = config.programs.oxwm; | 8 | + cfg = config.programs.oxwm.settings; |
| 9 | 9 | ||
| 10 | # Converts a nix submodule into a single oxwm bar block | 10 | # Converts a nix submodule into a single oxwm bar block |
| 11 | blockToLua = block: let | 11 | blockToLua = block: let |
| @@ -132,18 +132,54 @@ in { | |||
| 132 | }); | 132 | }); |
| 133 | default = []; | 133 | default = []; |
| 134 | description = "The list of keybinds"; | 134 | description = "The list of keybinds"; |
| 135 | - example = ''[ | 135 | + example = '' [ |
| 136 | - { | 136 | + { |
| 137 | - mods = [ "Mod4" "Shift" ]; | 137 | + mods = [ "Mod4" "Shift" ]; |
| 138 | - key = "Slash"; | 138 | + key = "Slash"; |
| 139 | - action = "oxwm.show_keybinds()"; | 139 | + action = "oxwm.show_keybinds()"; |
| 140 | - } | 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" ]; | 169 | + notes = [ |
| 143 | - key = "D"; | 170 | + { |
| 144 | - action = "oxwm.spawn({ "sh", "-c", "dmenu_run -l 10" })"; | 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 | border = { | 184 | border = { |
| 149 | width = mkOption { | 185 | width = mkOption { |
| @@ -261,7 +297,7 @@ in { | |||
| 261 | }; | 297 | }; |
| 262 | }); | 298 | }); |
| 263 | description = "The modules to put on the bar"; | 299 | description = "The modules to put on the bar"; |
| 264 | - example = ''[ | 300 | + example = '' [ |
| 265 | { | 301 | { |
| 266 | kind = "ram"; | 302 | kind = "ram"; |
| 267 | interval = 5; | 303 | interval = 5; |
| @@ -333,7 +369,7 @@ in { | |||
| 333 | }; | 369 | }; |
| 334 | }); | 370 | }); |
| 335 | description = "A list of window rules for the window manager to follow"; | 371 | description = "A list of window rules for the window manager to follow"; |
| 336 | - example = ''[ | 372 | + example = '' [ |
| 337 | { | 373 | { |
| 338 | match.class = "gimp"; | 374 | match.class = "gimp"; |
| 339 | floating = true; | 375 | floating = true; |
| @@ -354,13 +390,13 @@ in { | |||
| 354 | }; | 390 | }; |
| 355 | }; | 391 | }; |
| 356 | 392 | ||
| 357 | - config = mkIf cfg.enable { | 393 | + config = mkIf config.programs.oxwm.enable { |
| 358 | - home.packages = [cfg.package]; | 394 | + home.packages = [config.programs.oxwm.package]; |
| 359 | 395 | ||
| 360 | xsession.windowManager.command = '' | 396 | xsession.windowManager.command = '' |
| 361 | - ${cfg.extraSessionCommands} | 397 | + ${config.programs.oxwm.extraSessionCommands} |
| 362 | export _JAVA_AWT_WM_NONREPARENTING=1 | 398 | export _JAVA_AWT_WM_NONREPARENTING=1 |
| 363 | - exec ${getExe cfg.package} | 399 | + exec ${getExe config.programs.oxwm.package} |
| 364 | ''; | 400 | ''; |
| 365 | 401 | ||
| 366 | xdg.configFile."oxwm/config.lua".text = '' | 402 | xdg.configFile."oxwm/config.lua".text = '' |
| @@ -402,11 +438,20 @@ in { | |||
| 402 | oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action}) | 438 | oxwm.key.bind({ ${lib.concatMapStringsSep ", " (m: ''"${m}"'') bind.mods} }, "${bind.key}", ${bind.action}) |
| 403 | '') | 439 | '') |
| 404 | cfg.binds} | 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 | ${lib.concatMapStrings (rule: '' | 450 | ${lib.concatMapStrings (rule: '' |
| 407 | ${ruleToLua rule} | 451 | ${ruleToLua rule} |
| 408 | '') | 452 | '') |
| 409 | cfg.rules} | 453 | cfg.rules} |
| 454 | + ${cfg.extraConfig} | ||
| 410 | ''; | 455 | ''; |
| 411 | }; | 456 | }; |
| 412 | } | 457 | } |