# Reload yabai
ctrl + alt + cmd - r : launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai"# Application Shortcuts
#cmd + shift - f : open ~
cmd + shift - f : open -na /Applications/Firefox.app
cmd + shift - t : open -na /Applications/Ghostty.app
cmd + shift - s : open "x-apple.systempreferences:"
cmd + shift - c : open -na /Applications/Google\ Chrome.app
cmd + shift - e : open -na /Applications/Emacslient.app

alt - w : yabai -m window --close
# enter fullscreen mode for the focused container
alt - f : yabai -m window --toggle zoom-fullscreen
# toggle window native fullscreen
alt + shift - f : yabai -m window --toggle native-fullscreen
alt - t: yabai --stop-service
alt - s: yabai --start-service
alt - r: yabai --restart-service

# focus window in bsp mode
cmd - h: yabai -m window --focus west
cmd - j: yabai -m window --focus south
cmd - k: yabai -m window --focus north
cmd - l: yabai -m window --focus east

cmd + shift - 1 : yabai -m window --space  1; yabai -m space --focus 1
cmd + shift - 2 : yabai -m window --space  2; yabai -m space --focus 2
cmd + shift - 4 : yabai -m window --space  4; yabai -m space --focus 4
cmd + shift - 3 : yabai -m window --space  3; yabai -m space --focus 3
cmd + shift - 5 : yabai -m window --space  5; yabai -m space --focus 5
cmd + shift - 6 : yabai -m window --space  6; yabai -m space --focus 6
cmd + shift - 7 : yabai -m window --space  7; yabai -m space --focus 7
cmd + shift - 8 : yabai -m window --space  8; yabai -m space --focus 8
cmd + shift - 9 : yabai -m window --space  9; yabai -m space --focus 9
cmd + shift - 0 : yabai -m window --space 10; yabai -m space --focus 10

# fast focus desktop, note, this wont work on work computers (SA cannot be disabled)
alt - left : yabai -m space --focus prev
alt - right : yabai -m space --focus next
alt - z : yabai -m space --focus recent
alt - 1 : yabai -m space --focus 1
alt - 2 : yabai -m space --focus 2
alt - 3 : yabai -m space --focus 3
alt - 4 : yabai -m space --focus 4
alt - 5 : yabai -m space --focus 5
alt - 6 : yabai -m space --focus 6
alt - 7 : yabai -m space --focus 7
alt - 8 : yabai -m space --focus 8
alt - 9 : yabai -m space --focus 9
alt - 0 : yabai -m space --focus 10

ctrl + shift - space : yabai -m space --layout "$(yabai -m query --spaces --space | jq -r 'if .type == "bsp" then "stack" else "bsp" end')"

# forward
ctrl + shift - right : yabai -m query --spaces --space \
  | jq -re ".index" \
  | xargs -I{} yabai -m query --windows --space {} \
  | jq -sre "add | map(select(.minimized != 1)) | sort_by(.display, .frame.y, .frame.x, .id) | reverse | nth(index(map(select(.focused == 1))) - 1).id" \
  | xargs -I{} yabai -m window --focus {}

# backward
ctrl + shift - left: yabai -m query --spaces --space \
  | jq -re ".index" \
  | xargs -I{} yabai -m query --windows --space {} \
  | jq -sre "add | map(select(.minimized != 1)) | sort_by(.display, .frame.y, .frame.y, .id) | nth(index(map(select(.focused == 1))) - 1).id" \
  | xargs -I{} yabai -m window --focus {}

ctrl + shift - 1 : yabai -m window --space  1; yabai -m space --focus 1
ctrl + shift - 2 : yabai -m window --space  2; yabai -m space --focus 2
ctrl + shift - 3 : yabai -m window --space  3; yabai -m space --focus 3
ctrl + shift - 4 : yabai -m window --space  4; yabai -m space --focus 4
ctrl + shift - 5 : yabai -m window --space  5; yabai -m space --focus 5
ctrl + shift - 6 : yabai -m window --space  6; yabai -m space --focus 6
ctrl + shift - 7 : yabai -m window --space  7; yabai -m space --focus 7
ctrl + shift - 8 : yabai -m window --space  8; yabai -m space --focus 8
ctrl + shift - 9 : yabai -m window --space  9; yabai -m space --focus 9
ctrl + shift - 0 : yabai -m window --space 10; yabai -m space --focus 10

ctrl + cmd - h : yabai -m window west --resize right:-50:0 2> /dev/null || yabai -m window --resize right:-50:0
ctrl + cmd - j : yabai -m window north --resize bottom:0:50 2> /dev/null || yabai -m window --resize bottom:0:50
ctrl + cmd - k : yabai -m window south --resize top:0:-50 2> /dev/null || yabai -m window --resize top:0:-50
ctrl + cmd - l : yabai -m window east --resize left:50:0 2> /dev/null || yabai -m window --resize left:50:0
