home/sway: add windowManagerBinds to sway (#61)
Some checks are pending
flakehub / flakehub-publish (push) Waiting to run
git-mirror / gitlab-sync (push) Waiting to run
nix-build / default-build (push) Waiting to run
nix-build / fallarbor-build (push) Waiting to run
nix-build / lavaridge-build (push) Waiting to run
nix-build / mauville-build (push) Waiting to run
nix-build / petalburg-build (push) Waiting to run
nix-build / rustboro-build (push) Waiting to run
nix-check / fmt-check (push) Waiting to run
nix-check / eval-check (push) Waiting to run

* home/sway: add windowManagerBinds to sway

* home/sway: simplify modes
This commit is contained in:
Aly Raffauf 2024-07-23 21:02:33 -04:00 committed by GitHub
parent 88f3e8434a
commit 25112a550c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 76 additions and 121 deletions

View file

@ -80,129 +80,69 @@ in {
}; };
}; };
keybindings = { keybindings =
# Apps {
"${modifier}+B" = "exec ${lib.getExe cfg.defaultApps.webBrowser}"; "${modifier}+B" = "exec ${lib.getExe cfg.defaultApps.webBrowser}";
"${modifier}+E" = "exec ${lib.getExe cfg.defaultApps.editor}"; "${modifier}+C" = "kill";
"${modifier}+F" = "exec ${lib.getExe cfg.defaultApps.fileManager}"; "${modifier}+Comma" = "workspace prev";
"${modifier}+R" = "exec ${lib.getExe pkgs.fuzzel}"; "${modifier}+Control+L" = "exec ${lib.getExe pkgs.swaylock}";
"${modifier}+T" = "exec ${lib.getExe cfg.defaultApps.terminal}"; "${modifier}+E" = "exec ${lib.getExe cfg.defaultApps.editor}";
"${modifier}+F" = "exec ${lib.getExe cfg.defaultApps.fileManager}";
# Manage session. "${modifier}+F11" = "exec pkill -SIGUSR1 waybar"; # Show/hide waybar
"${modifier}+C" = "kill"; "${modifier}+M" = "exec ${lib.getExe pkgs.wlogout}";
"${modifier}+Control+L" = "exec ${lib.getExe pkgs.swaylock}"; "${modifier}+Period" = "workspace next";
"${modifier}+M" = "exec ${lib.getExe pkgs.wlogout}"; "${modifier}+R" = "exec ${lib.getExe pkgs.fuzzel}";
"${modifier}+S" = "scratchpad show";
# Basic window management. "${modifier}+Shift+Comma" = "move container to workspace prev; workspace prev";
"${modifier}+Shift+W" = "fullscreen toggle"; "${modifier}+Shift+Period" = "move container to workspace next; workspace next";
"${modifier}+Shift+V" = "floating toggle"; "${modifier}+Shift+S" = "move scratchpad";
"${modifier}+Shift+V" = "floating toggle";
# Move focus with modifier + arrow keys "${modifier}+Shift+W" = "fullscreen toggle";
"${modifier}+Left" = "focus left"; "${modifier}+T" = "exec ${lib.getExe cfg.defaultApps.terminal}";
"${modifier}+Down" = "focus down"; "Control+F12" = "exec ${helpers.screenshot}";
"${modifier}+Up" = "focus up"; "Ctrl+Mod1+M" = "mode move";
"${modifier}+Right" = "focus right"; "Ctrl+Mod1+R" = "mode resize";
"PRINT" = "exec ${helpers.screenshot}";
# Move focus with modifier + hjkl keys (vim/ADM-3A terminal) }
"${modifier}+H" = "focus left"; // builtins.listToAttrs (
"${modifier}+J" = "focus down"; builtins.concatMap (workspace: [
"${modifier}+K" = "focus up"; {
"${modifier}+L" = "focus right"; name = "${modifier}+${toString workspace}";
value = "workspace number ${toString workspace}";
# Move window with modifier SHIFT + arrow keys }
"${modifier}+Shift+Left" = "move left"; {
"${modifier}+Shift+Down" = "move down"; name = "${modifier}+Shift+${toString workspace}";
"${modifier}+Shift+Up" = "move up"; value = "move container to workspace number ${toString workspace}; workspace ${toString workspace}";
"${modifier}+Shift+Right" = "move right"; }
]) [1 2 3 4 5 6 7 8 9]
# Move window with modifier SHIFT + hjkl keys )
"${modifier}+Shift+H" = "move left"; // lib.attrsets.concatMapAttrs
"${modifier}+Shift+J" = "move down"; (key: direction: {
"${modifier}+Shift+K" = "move up"; "${modifier}+${key}" = "focus ${direction}";
"${modifier}+Shift+L" = "move right"; "${modifier}+Shift+${key}" = "move ${direction}";
"${modifier}+Control+Shift+${key}" = "move workspace to output ${direction}";
# Gnome-like workspaces. })
"${modifier}+Comma" = "workspace prev"; cfg.desktop.sway.windowManagerBinds;
"${modifier}+Period" = "workspace next";
"${modifier}+Shift+Comma" = "move container to workspace prev; workspace prev";
"${modifier}+Shift+Period" = "move container to workspace next; workspace next";
# Switch workspaces with modifier + [0-9]
"${modifier}+1" = "workspace number 1";
"${modifier}+2" = "workspace number 2";
"${modifier}+3" = "workspace number 3";
"${modifier}+4" = "workspace number 4";
"${modifier}+5" = "workspace number 5";
"${modifier}+6" = "workspace number 6";
"${modifier}+7" = "workspace number 7";
"${modifier}+8" = "workspace number 8";
"${modifier}+9" = "workspace number 9";
"${modifier}+0" = "workspace number 10";
# Move active window to a workspace with modifier + SHIFT + [0-9]
"${modifier}+Shift+1" = "move container to workspace number 1; workspace 1";
"${modifier}+Shift+2" = "move container to workspace number 2; workspace 2";
"${modifier}+Shift+3" = "move container to workspace number 3; workspace 3";
"${modifier}+Shift+4" = "move container to workspace number 4; workspace 4";
"${modifier}+Shift+5" = "move container to workspace number 5; workspace 5";
"${modifier}+Shift+6" = "move container to workspace number 6; workspace 6";
"${modifier}+Shift+7" = "move container to workspace number 7; workspace 7";
"${modifier}+Shift+8" = "move container to workspace number 8; workspace 8";
"${modifier}+Shift+9" = "move container to workspace number 9; workspace 9";
"${modifier}+Shift+0" = "move container to workspace number 10; workspace 10";
# Move workspace to another output.
"${modifier}+Control+Shift+Left" = "move workspace to output left";
"${modifier}+Control+Shift+Down" = "move workspace to output down";
"${modifier}+Control+Shift+Up" = "move workspace to output up";
"${modifier}+Control+Shift+Right" = "move workspace to output right";
# Move workspace to another output.
"${modifier}+Control+Shift+H" = "move workspace to output left";
"${modifier}+Control+Shift+J" = "move workspace to output down";
"${modifier}+Control+Shift+K" = "move workspace to output up";
"${modifier}+Control+Shift+L" = "move workspace to output right";
# Scratchpad show and move
"${modifier}+S" = "scratchpad show";
"${modifier}+Shift+S" = "move scratchpad";
# Screenshots
"PRINT" = "exec ${helpers.screenshot}";
"Control+F12" = "exec ${helpers.screenshot}";
# Show/hide waybar
"${modifier}+F11" = "exec pkill -SIGUSR1 waybar";
"Ctrl+Mod1+M" = "mode move";
"Ctrl+Mod1+R" = "mode resize";
};
modes = { modes = {
move = { move =
Escape = "mode default"; {
Left = "move left"; Comma = "move container to workspace prev; workspace prev";
Down = "move down"; Escape = "mode default";
Up = "move up"; Period = "move container to workspace next; workspace next";
Right = "move right"; S = "move scratchpad";
H = "move left"; }
J = "move down"; // builtins.listToAttrs (
K = "move up"; builtins.concatMap (workspace: [
L = "move right"; {
Comma = "move container to workspace prev; workspace prev"; name = toString workspace;
Period = "move container to workspace next; workspace next"; value = "move container to workspace number ${toString workspace}; workspace ${toString workspace}";
"1" = "move container to workspace number 1; workspace 1"; }
"2" = "move container to workspace number 2; workspace 2"; ]) [1 2 3 4 5 6 7 8 9]
"3" = "move container to workspace number 3; workspace 3"; )
"4" = "move container to workspace number 4; workspace 4"; // lib.attrsets.concatMapAttrs
"5" = "move container to workspace number 5; workspace 5"; (key: direction: {"${key}" = "move ${direction}";})
"6" = "move container to workspace number 6; workspace 6"; cfg.desktop.sway.windowManagerBinds;
"7" = "move container to workspace number 7; workspace 7";
"8" = "move container to workspace number 8; workspace 8";
"9" = "move container to workspace number 9; workspace 9";
"0" = "move container to workspace number 10; workspace 10";
S = "move scratchpad";
};
resize = { resize = {
Escape = "mode default"; Escape = "mode default";

View file

@ -213,6 +213,21 @@ in {
default = cfg.desktop.sway.enable; default = cfg.desktop.sway.enable;
type = lib.types.bool; type = lib.types.bool;
}; };
windowManagerBinds = lib.mkOption {
description = "Default binds for window management.";
default = {
Down = "down";
Left = "left";
Right = "right";
Up = "up";
H = "left";
J = "down";
K = "up";
L = "right";
};
type = lib.types.attrs;
};
}; };
}; };