start-at-login = true
# Mouse follows focus when focused monitor changes
on-focused-monitor-changed = ['move-mouse monitor-lazy-center']

# Sketchybar Integration
after-startup-command = ['exec-and-forget sketchybar']

# Notify Sketchybar about workspace change
exec-on-workspace-change = [
'/bin/bash', '-c',
'sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$AEROSPACE_FOCUSED_WORKSPACE'
]

on-focus-changed = [
'exec-and-forget sketchybar --trigger front_app_switched',
'exec-and-forget --trigger update_windows'
]

enable-normalization-flatten-containers = false
enable-normalization-opposite-orientation-for-nested-containers = false

[gaps]
inner.horizontal = 5
inner.vertical = 5
outer.top = 45
outer.left = 5
outer.bottom = 5
outer.right = 5

[mode.main.binding]
# See: https://nikitabobko.github.io/AeroSpace/goodness#open-a-new-window-with-applescript
cmd-enter = '''exec-and-forget osascript << EOF
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
EOF'''
cmd-shift-e = 'exec-and-forget /etc/profiles/per-user/*/bin/emacs'
cmd-shift-f = 'exec-and-forget open -n -a "Firefox"'
cmd-shift-d = 'exec-and-forget open -n -a "Discord"'

# i3 wraps focus by default
cmd-h = 'focus --boundaries-action wrap-around-the-workspace left'
cmd-j = 'focus --boundaries-action wrap-around-the-workspace down'
cmd-k = 'focus --boundaries-action wrap-around-the-workspace up'
cmd-l = 'focus --boundaries-action wrap-around-the-workspace right'

cmd-shift-h = 'move left'
cmd-shift-j = 'move down'
cmd-shift-k = 'move up'
cmd-shift-l = 'move right'

cmd-f = 'fullscreen'
cmd-s = 'layout v_accordion' # 'layout stacking' in i3
cmd-e = 'layout tiles horizontal vertical' # 'layout toggle split' in i3
cmd-q = 'close'
cmd-semicolon = 'split horizontal' # split in horizontal orientation

cmd-shift-space = 'layout floating tiling' # 'floating toggle' in i3

# Not supported, because this command is redundant in AeroSpace mental model.
# See: https://nikitabobko.github.io/AeroSpace/guide#floating-windows
#cmd-space = 'focus toggle_tiling_floating'

# `focus parent`/`focus child` are not yet supported, and it's not clear whether they
# should be supported at all https://github.com/nikitabobko/AeroSpace/issues/5
# cmd-a = 'focus parent'

cmd-1 = 'workspace 1'
cmd-2 = 'workspace 2'
cmd-3 = 'workspace 3'
cmd-4 = 'workspace 4'
cmd-5 = 'workspace 5'
cmd-6 = 'workspace 6'
cmd-7 = 'workspace 7'
cmd-8 = 'workspace 8'
cmd-9 = 'workspace 9'
cmd-0 = 'workspace 10'

cmd-shift-1 = 'move-node-to-workspace 1'
cmd-shift-2 = 'move-node-to-workspace 2'
cmd-shift-3 = 'move-node-to-workspace 3'
cmd-shift-4 = 'move-node-to-workspace 4'
cmd-shift-5 = 'move-node-to-workspace 5'
cmd-shift-6 = 'move-node-to-workspace 6'
cmd-shift-7 = 'move-node-to-workspace 7'
cmd-shift-8 = 'move-node-to-workspace 8'
cmd-shift-9 = 'move-node-to-workspace 9'
cmd-shift-0 = 'move-node-to-workspace 10'

cmd-shift-c = 'reload-config'

cmd-shift-r = 'mode resize'

[mode.resize.binding]
h = 'resize width +50'
j = 'resize height -50'
k = 'resize height +50'
l = 'resize width -50'
enter = 'mode main'
esc = 'mode main'
