From 209055fba821f68497cd611ab163b92b7e8a674a Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Mon, 6 May 2024 14:08:52 +0100 Subject: [PATCH] Start adding sway --- hosts/common/graphical/default.nix | 1 + users/configs/desktop/default.nix | 3 +- users/configs/desktop/sway/default.nix | 108 +++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 users/configs/desktop/sway/default.nix diff --git a/hosts/common/graphical/default.nix b/hosts/common/graphical/default.nix index c2ef7c7..5ed1b61 100644 --- a/hosts/common/graphical/default.nix +++ b/hosts/common/graphical/default.nix @@ -52,6 +52,7 @@ programs = { hyprland.enable = true; + sway.enable = true; river = { enable = true; diff --git a/users/configs/desktop/default.nix b/users/configs/desktop/default.nix index 11cb903..a4f7f97 100644 --- a/users/configs/desktop/default.nix +++ b/users/configs/desktop/default.nix @@ -5,7 +5,8 @@ # ./polybar ./hyprland ./river - ./waybar + ./sway ./tofi + ./waybar ]; } diff --git a/users/configs/desktop/sway/default.nix b/users/configs/desktop/sway/default.nix new file mode 100644 index 0000000..58a2dc5 --- /dev/null +++ b/users/configs/desktop/sway/default.nix @@ -0,0 +1,108 @@ +{ + config, + lib, + pkgs, + ... +}: let + closer = pkgs.writeShellApplication { + name = "closer"; + + runtimeInputs = with pkgs; [jq xdotool]; + + text = '' + if [ "$(hyprctl activewindow -j | jq -r ".class")" = "Steam" ]; then + xdotool getactivewindow windowunmap + else + sway killactive "" + fi + ''; + }; + mod = "Mod4"; + hyper = "Control+Shift+Mod1"; +in { + wayland.windowManager.sway = { + enable = true; + config = { + input = { + "*" = { + xkb_layout = "gb"; + xkb_options= "caps:escape"; + } + }; + output = { + eDP-1 = { + scale = "1.33"; + }; + }; + keybindings = { + "${mod}+Return" = "exec kitty"; + "${mod}+q" = "${closer}/bin/closer"; + "${mod}+d" = "exec tofi-drun --drun-launch=true"; + + "${mod}+h" = "focus left"; + "${mod}+j" = "focus down"; + "${mod}+k" = "focus up"; + "${mod}+l" = "focus right"; + + "${mod}+Left" = "movewindow left"; + "${mod}+Up" = "movewindow up"; + "${mod}+Down" = "movewindow down"; + "${mod}+Right" = "movewindow right"; + + "${mod}+Shift+h" = "move window workspace prev"; + "${mod}+Shift+l" = "move window workspace next"; + + "${mod}+Control+h" = "workspace prev"; + "${mod}+Control+l" = "workspace next"; + + "${hyper}+y" = "move left"; + "${hyper}+o" = "move right"; + + "${mod}+Tab" = "workspace back_and_forth"; + "${hyper}+Tab" = "workspace back_and_forth"; + + "${mod}+b" = "split h"; + "${mod}+v" = "split v"; + + "${hyper}+b" = "split h"; + "${hyper}+v" = "split v"; + + "${mod}+Control+Return" = "exec --no-startup-id i3utils workspace new"; + "${mod}+Control+Shift+Return" = "exec --no-startup-id i3utils workspace new -b"; + "${mod}+Shift+Return" = "exec --no-startup-id i3utils workspace new -n, move next"; + + # "${mod}+Control+j" = "exec --no-startup-id $HOME/bin/scripts/godown"; + # "${mod}+Control+k" = "exec --no-startup-id $HOME/bin/scripts/goup"; + # "${mod}+Control+u" = "exec --no-startup-id $HOME/bin/scripts/godown"; + # "${mod}+Control+i" = "exec --no-startup-id $HOME/bin/scripts/goup"; + # "${mod}+Control+h" = "exec --no-startup-id i3utils workspace new -b"; + + "${hyper}+m" = "exec --no-startup-id $HOME/bin/scripts/godown"; + "${hyper}+comma" = "exec --no-startup-id $HOME/bin/scripts/goup"; + + "${mod}+Shift+k" = "exec --no-startup-id i3utils window move prev"; + "${mod}+Shift+j" = "exec --no-startup-id i3utils window move next"; + + "${hyper}+i" = "exec --no-startup-id i3utils window move prev"; + "${hyper}+u" = "exec --no-startup-id i3utils window move next"; + + "${mod}+p" = "scratchpad show, resize set 80 ppt 80ppt, move position center"; + "${hyper}+p" = "scratchpad show, resize set 80 ppt 80ppt, move position center"; + + "${mod}+Escape" = "exec loginctl lock-session"; + "${hyper}+Escape" = "exec loginctl lock-session"; + + "${hyper}+f" = "fullscreen toggle"; + + "XF86MonBrightnessUp" = "exec xbacklight -inc 10"; + "XF86MonBrightnessDown" = "exec xbacklight -dec 10"; + "XF86AudioMute" = "exec pamixer -t"; + "XF86AudioLowerVolume" = "exec pamixer -d 5"; + "XF86AudioRaiseVolume" = "exec pamixer -i 5"; + "XF86AudioPrev" = "exec playerctl previous"; + "XF86AudioPlay" = "exec playerctl play-pause"; + "XF86AudioNext" = "exec playerctl next"; + }; + }; + }; +}