Add workspace keybinds
This commit is contained in:
parent
4f21c610a5
commit
4a45f67fa4
1 changed files with 24 additions and 4 deletions
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue