{ pkgs, lib, config, ... }: { options.custom = with lib; { aerospace = { enable = mkEnableOption "Enable aerospace"; }; }; config = lib.mkIf config.custom.aerospace.enable { services.aerospace = { enable = config.custom.aerospace.enable; settings = { enable-normalization-flatten-containers = true; enable-normalization-opposite-orientation-for-nested-containers = true; accordion-padding = 0; on-focused-monitor-changed = [ "move-mouse monitor-lazy-center" ]; default-root-container-layout = "tiles"; default-root-container-orientation = "auto"; gaps = { inner = { horizontal = 0; vertical = 0; }; outer = { left = 0; bottom = 0; top = 0; right = 0; }; }; mode = { main = { binding = { alt-enter = let script = pkgs.writeText "ghostty.applescript" '' do shell script "open -n -a Ghostty" ''; in "exec-and-forget osascript ${script}"; alt-shift-f = "fullscreen"; alt-p = "layout floating tiling"; alt-e = "layout tiles horizontal vertical"; alt-t = "layout accordion horizontal vertical"; alt-h = "focus left"; alt-l = "focus right"; alt-shift-h = "move left"; alt-shift-l = "move right"; 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"; alt-0 = "workspace 10"; alt-shift-1 = [ "move-node-to-workspace 1" "workspace 1" ]; alt-shift-2 = [ "move-node-to-workspace 2" "workspace 2" ]; alt-shift-3 = [ "move-node-to-workspace 3" "workspace 3" ]; alt-shift-4 = [ "move-node-to-workspace 4" "workspace 4" ]; alt-shift-5 = [ "move-node-to-workspace 5" "workspace 5" ]; alt-shift-6 = [ "move-node-to-workspace 6" "workspace 6" ]; alt-shift-7 = [ "move-node-to-workspace 7" "workspace 7" ]; alt-shift-8 = [ "move-node-to-workspace 8" "workspace 8" ]; alt-shift-9 = [ "move-node-to-workspace 9" "workspace 9" ]; alt-shift-0 = [ "move-node-to-workspace 10" "workspace 10" ]; alt-r = "mode resize"; }; }; resize = { binding = { h = "resize width -50"; j = "resize height +50"; k = "resize height -50"; l = "resize width +50"; enter = "mode main"; esc = "mode main"; }; }; }; on-window-detected = [ { "if".app-id = "com.mitchellh.ghostty"; run = [ "layout tiling" ]; } ]; }; }; }; }