{ pkgs, lib, config, ... }: let mod = "Mod4"; cfg = config.custom.gui; # 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 ); sc = with pkgs; (writeScriptBin "sc" '' ${slurp}/bin/slurp | ${grim}/bin/grim -g - - | ${wl-clipboard}/bin/wl-copy -t image/png ''); vol = ../../../script/vol; in with lib; { options.custom.gui.wm = with types; { workspaces.named = mkOption { type = attrsOf str; default = {}; }; workspaces.numbered = mkOption { type = int; default = 8; }; }; config = mkIf (cfg.enable) { home.packages = with pkgs; [ kitty wl-clipboard sc (writeScriptBin "c" '' ${wl-clipboard}/bin/wl-copy '') (writeScriptBin "p" '' ${wl-clipboard}/bin/wl-paste '') ]; services.unclutter.enable = true; wayland.windowManager.sway = { # This is all required to get it to not die. enable = true; wrapperFeatures.gtk = true; systemd.enable = true; extraConfig = '' bindsym --release ${mod}+d exec ${sc}/bin/sc ''; config = rec { output."*".bg = "${../../data/wallpaper.jpg} fill"; input."type:keyboard".xkb_options = "caps:super"; terminal = "kitty --single-instance"; bars = []; gaps = { inner = 4; outer = 2; }; colors = { focused = rec { text = "#ffffff"; border = "#7c56c4"; background = border; childBorder = border; indicator = border; }; }; # Directional keys modifier = mod; fonts = { names = [ "Fira Code" ]; size = 8.0; }; keybindings = let mpc = "${pkgs.mpc-cli}/bin/mpc"; in mkMerge [ (genWorkspaces { inherit (cfg.wm.workspaces) numbered named; }) { "${mod}+h" = "focus left"; "${mod}+j" = "focus down"; "${mod}+k" = "focus up"; "${mod}+l" = "focus right"; "${mod}+semicolon" = "workspace prev_on_output"; "${mod}+apostrophe" = "workspace next_on_output"; "${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}+Escape" = "exec swaylock"; "${mod}+Return" = "exec ${terminal}"; "${mod}+Alt+Return" = "exec ${pkgs.foot}/bin/foot"; "${mod}+Tab" = "exec ${pkgs.firefox-wayland}/bin/firefox"; "${mod}+Alt+Tab" = "exec ${pkgs.google-chrome}/bin/google-chrome-stable --ozone-platform-hint=auto --enable-features=VaapiVideoDecoder,VaapiVideoEncoder"; "${mod}+Backspace" = "mode kill"; "XF86AudioRaiseVolume" = "exec ${vol} raise"; "XF86AudioLowerVolume" = "exec ${vol} lower"; "XF86AudioMute" = "exec ${vol} toggle"; "XF86AudioPlay" = "exec ${mpc} toggle"; "${mod}+z" = "exec ${vol} lower"; "${mod}+x" = "exec ${vol} raise"; "${mod}+comma" = "exec ${mpc} prev"; "${mod}+period" = "exec ${mpc} next"; "${mod}+slash" = "exec ${mpc} toggle"; } ]; modes."kill" = { Backspace = "kill; mode default"; Escape = "mode default"; }; window.titlebar = false; }; }; }; }