nix/darwin/aerospace.nix
2025-04-08 22:53:50 -05:00

243 lines
6.5 KiB
Nix

{
pkgs,
lib,
config,
home-dir,
...
}:
let
cfg = config.custom.aerospace;
in
{
options.custom = with lib; {
aerospace = {
enable = mkEnableOption "Enable aerospace";
logFile = mkOption {
type = types.str;
default = "${home-dir}/Library/Logs/aerospace.log";
description = "Filepath of log output";
};
};
};
config = lib.mkIf cfg.enable {
launchd.user.agents.aerospace.serviceConfig = {
StandardErrorPath = cfg.logFile;
StandardOutPath = cfg.logFile;
};
services.aerospace = {
enable = true;
settings = {
enable-normalization-flatten-containers = false;
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 = 15;
vertical = 15;
};
outer = {
left = 10;
bottom = 5;
top = [
{ monitor."LG ULTRAWIDE" = 50; }
{ monitor."ZOWIE XL LCD" = 50; }
12
];
right = 10;
};
};
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-enter = "exec-and-forget \"open -n -a /Applications/Slack.app\"";
alt-shift-f = "fullscreen";
alt-shift-q = "close --quit-if-last-window";
alt-space = "layout floating tiling";
alt-e = "layout tiles horizontal vertical";
alt-t = "layout h_accordion";
alt-s = "layout v_accordion";
alt-v = "split vertical";
alt-shift-v = "split horizontal";
# alt-v = "join-with down";
# alt-shift-v = "join-with right";
alt-h = "focus left";
alt-l = "focus right";
alt-j = "focus down";
alt-k = "focus up";
alt-shift-h = "move left";
alt-shift-l = "move right";
alt-shift-j = "move down";
alt-shift-k = "move up";
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-tab = "workspace-back-and-forth";
alt-shift-tab = "move-workspace-to-monitor --wrap-around next";
alt-r = "mode resize";
alt-shift-semicolon = "mode service";
};
};
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" ];
};
};
resize = {
binding = {
h = "resize width -50";
j = "resize height +50";
k = "resize height -50";
l = "resize width +50";
enter = "mode main";
esc = "mode main";
};
};
};
workspace-to-monitor-force-assignment = {
"1" = "main";
"2" = "main";
"3" = "main";
"4" = "main";
"5" = "main";
"6" = "main";
"7" = [
"2"
"main"
];
"8" = "main";
"9" = "main";
"10" = [
"2"
"main"
];
};
on-window-detected = [
{
"if".app-id = "com.spotify.client";
run = [ "move-node-to-workspace 7" ];
}
{
"if".app-id = "app.zen-browser.zen";
run = [ "move-node-to-workspace 10" ];
}
{
"if".app-id = "com.mitchellh.ghostty";
run = [ "layout tiling" ];
}
{
"if".app-id = "com.tinyspeck.slackmacgap";
run = [ "move-node-to-workspace 9" ];
}
];
};
};
};
}