{ pkgs, lib, config, ... }: let inherit (lib) mkEnableOption mkIf; cfg = config.my.aerospace; in { options.my.aerospace = { enable = mkEnableOption "aerospace"; }; config = mkIf cfg.enable { services.aerospace = { enable = true; package = pkgs.unstable.aerospace; settings = { # Startup configuration after-login-command = []; after-startup-command = []; # Layout normalization enable-normalization-flatten-containers = true; enable-normalization-opposite-orientation-for-nested-containers = true; # Layout settings accordion-padding = 30; default-root-container-layout = "tiles"; default-root-container-orientation = "auto"; # Mouse behavior on-focused-monitor-changed = ["move-mouse monitor-lazy-center"]; automatically-unhide-macos-hidden-apps = false; # Key mapping key-mapping = { preset = "qwerty"; }; # Window gaps gaps = { inner = { horizontal = 2; vertical = 2; }; outer = { left = 0; bottom = 0; top = [ {monitor."built-in" = 2;} 35 ]; right = 0; }; }; # Main mode bindings mode.main.binding = { # Layout commands "alt-slash" = "layout tiles horizontal vertical"; "alt-comma" = "layout accordion horizontal vertical"; # Focus commands "alt-h" = "focus left"; "alt-j" = "focus down"; "alt-k" = "focus up"; "alt-l" = "focus right"; # Move commands "alt-shift-h" = "move left"; "alt-shift-j" = "move down"; "alt-shift-k" = "move up"; "alt-shift-l" = "move right"; # Resize commands "alt-minus" = "resize smart -50"; "alt-equal" = "resize smart +50"; # Misc window commands "alt-q" = "close"; # Workspace commands "alt-1" = "workspace 1"; "alt-2" = "workspace 2"; "alt-3" = "workspace 3"; "alt-4" = "workspace 4"; "alt-5" = "workspace 5"; "alt-6" = "workspace 6"; "alt-7" = "workspace 7"; "alt-8" = "workspace 8"; "alt-9" = "workspace 9"; # Move node to workspace commands "alt-shift-1" = "move-node-to-workspace 1"; "alt-shift-2" = "move-node-to-workspace 2"; "alt-shift-3" = "move-node-to-workspace 3"; "alt-shift-4" = "move-node-to-workspace 4"; "alt-shift-5" = "move-node-to-workspace 5"; "alt-shift-6" = "move-node-to-workspace 6"; "alt-shift-7" = "move-node-to-workspace 7"; "alt-shift-8" = "move-node-to-workspace 8"; "alt-shift-9" = "move-node-to-workspace 9"; # Applications "alt-t" = '' exec-and-forget osascript -e ' tell application "Ghostty" if it is running then activate tell application "System Events" to keystroke "n" using {command down} else activate end if end tell' ''; "alt-f" = "exec-and-forget open -n '/Applications/Zen Browser.app'"; # Other commands # "alt-tab" = "workspace-back-and-forth"; # "alt-shift-tab" = "move-workspace-to-monitor --wrap-around next"; "alt-shift-semicolon" = "mode service"; }; # Service mode bindings mode.service.binding = { "esc" = ["reload-config" "mode main"]; "r" = ["flatten-workspace-tree" "mode main"]; "f" = ["layout floating tiling" "mode main"]; "backspace" = ["close-all-windows-but-current" "mode main"]; "alt-shift-h" = ["join-with left" "mode main"]; "alt-shift-j" = ["join-with down" "mode main"]; "alt-shift-k" = ["join-with up" "mode main"]; "alt-shift-l" = ["join-with right" "mode main"]; "down" = "volume down"; "up" = "volume up"; "shift-down" = ["volume set 0" "mode main"]; }; }; }; }; }