From e4a14d6c24704f443d43a40fdc73223465c8a238 Mon Sep 17 00:00:00 2001 From: Riley Apeldoorn Date: Mon, 22 May 2023 15:38:39 +0000 Subject: [PATCH] Add sway keybinds --- flake.nix | 4 +-- shared/home/gui/sway.nix | 57 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 182dee4..cab68bf 100644 --- a/flake.nix +++ b/flake.nix @@ -18,9 +18,7 @@ config = { home-manager.users."riley" = a: lib.pipe a [ (import path) - (x: x // { - imports = [ ./shared/home ]; - }) + (x: x // { imports = [ ./shared/home ]; }) ]; }; }; in { diff --git a/shared/home/gui/sway.nix b/shared/home/gui/sway.nix index 7624770..43992e3 100644 --- a/shared/home/gui/sway.nix +++ b/shared/home/gui/sway.nix @@ -10,7 +10,19 @@ in with lib; { config = mkIf (cfg.enable) { - home.packages = []; + home.packages = with pkgs; [ + wl-clipboard + (writeScriptBin "c" '' + ${wl-clipboard}/bin/wl-copy + '') + (writeScriptBin "p" '' + ${wl-clipboard}/bin/wl-paste + '') + ]; + + programs.swaylock.enable = true; + programs.waybar.enable = true; + services.swayidle.enable = true; wayland.windowManager.sway = { # This is all required to get it to not die. @@ -18,9 +30,50 @@ in with lib; { extraSessionCommands = "export WLR_NO_HARDWARE_CURSORS=1"; extraOptions = [ "--unsupported-gpu" ]; - config = { + config = rec { output."*".bg = "${../../data/wallpaper.jpg} fill"; + input."type:keyboard".xkb_options = "caps:escape"; + terminal = "${pkgs.kitty}/bin/kitty"; + + # Directional keys + modifier = "Mod4"; + fonts = { + names = [ "Fira Code" ]; + size = 8.0; + }; + + keybindings = let mod = modifier; in { + "${mod}+h" = "focus left"; + "${mod}+j" = "focus down"; + "${mod}+k" = "focus up"; + "${mod}+l" = "focus right"; + + "${mod}+Shift+h" = "move left"; + "${mod}+Shift+j" = "move down"; + "${mod}+Shift+k" = "move up"; + "${mod}+Shift+l" = "move right"; + + "${mod}+a" = "split v"; + "${mod}+s" = "split h"; + "${mod}+f" = "fullscreen toggle"; + + "${mod}+Alt+a" = "layout toggle stacking splitv"; + "${mod}+Alt+s" = "layout toggle tabbed splith"; + + "${mod}+Return" = "exec ${terminal}"; + "${mod}+Escape" = "exec ${pkgs.swaylock}/bin/swaylock"; + "${mod}+Tab" = "exec ${pkgs.firefox}/bin/firefox"; + + "${mod}+Backspace" = "mode kill"; + }; + + modes."kill" = { + Backspace = "kill; mode default"; + Escape = "mode default"; + }; + + window.titlebar = true; }; };