diff --git a/shared/home/gui/sway.nix b/shared/home/gui/sway.nix index 43992e3..346cd73 100644 --- a/shared/home/gui/sway.nix +++ b/shared/home/gui/sway.nix @@ -1,11 +1,31 @@ { pkgs, lib, config, ... }: -let cfg = config.custom.gui.sway; +let mod = "Mod4"; + cfg = config.custom.gui.sway; + + # Generate the workspace keybinds + genWorkspaces = { numbered, named }: with lib; ( + let nums = genAttrs (map toString (range 1 (min numbered 9))) id; + genBindings = (num: key: { + "${mod}+${key}" = "workspace ${num}"; + "${mod}+Shift+${key}" = "move window to workspace ${num}"; + }); + keybinds = mapAttrsToList genBindings (nums // named); + in mkMerge keybinds + ); in with lib; { - options.custom.gui.sway = { + options.custom.gui.sway = with types; { enable = mkEnableOption "sway window manager"; + workspaces.named = mkOption { + type = attrsOf str; + default = {}; + }; + workspaces.numbered = mkOption { + type = int; + default = 5; + }; }; config = mkIf (cfg.enable) { @@ -37,13 +57,13 @@ in with lib; { terminal = "${pkgs.kitty}/bin/kitty"; # Directional keys - modifier = "Mod4"; + modifier = mod; fonts = { names = [ "Fira Code" ]; size = 8.0; }; - keybindings = let mod = modifier; in { + keybindings = (genWorkspaces { inherit (cfg.workspaces) numbered named; }) // { "${mod}+h" = "focus left"; "${mod}+j" = "focus down"; "${mod}+k" = "focus up";