#!/usr/bin/env bash # # I have set the "FN" key on my Planck to the "Meh" action which just fires # the Ctrl+Shift+Alt key combo which helps here to have unique skhd shortcuts # that don't clash with macOS/Neovim/... # Focus a window alt - h : yabai -m window --focus west alt - j : yabai -m window --focus south alt - k : yabai -m window --focus north alt - l : yabai -m window --focus east # Focus a space ctrl + shift + alt - 1 : index=1; eval "$(yabai -m query --spaces | jq --argjson index "${index}" -r '(.[] | select(.index == $index).windows[0]) as $wid | if $wid then "yabai -m window --focus \"" + ($wid | tostring) + "\"" else "skhd --key \"ctrl - " + (map(select(."is-native-fullscreen" == false)) | index(map(select(.index == $index))) + 1 % 10 | tostring) + "\"" end')" ctrl + shift + alt - 2 : index=2; eval "$(yabai -m query --spaces | jq --argjson index "${index}" -r '(.[] | select(.index == $index).windows[0]) as $wid | if $wid then "yabai -m window --focus \"" + ($wid | tostring) + "\"" else "skhd --key \"ctrl - " + (map(select(."is-native-fullscreen" == false)) | index(map(select(.index == $index))) + 1 % 10 | tostring) + "\"" end')" ctrl + shift + alt - 3 : index=3; eval "$(yabai -m query --spaces | jq --argjson index "${index}" -r '(.[] | select(.index == $index).windows[0]) as $wid | if $wid then "yabai -m window --focus \"" + ($wid | tostring) + "\"" else "skhd --key \"ctrl - " + (map(select(."is-native-fullscreen" == false)) | index(map(select(.index == $index))) + 1 % 10 | tostring) + "\"" end')" ctrl + shift + alt - 4 : index=4; eval "$(yabai -m query --spaces | jq --argjson index "${index}" -r '(.[] | select(.index == $index).windows[0]) as $wid | if $wid then "yabai -m window --focus \"" + ($wid | tostring) + "\"" else "skhd --key \"ctrl - " + (map(select(."is-native-fullscreen" == false)) | index(map(select(.index == $index))) + 1 % 10 | tostring) + "\"" end')" ctrl + shift + alt - 5 : index=5; eval "$(yabai -m query --spaces | jq --argjson index "${index}" -r '(.[] | select(.index == $index).windows[0]) as $wid | if $wid then "yabai -m window --focus \"" + ($wid | tostring) + "\"" else "skhd --key \"ctrl - " + (map(select(."is-native-fullscreen" == false)) | index(map(select(.index == $index))) + 1 % 10 | tostring) + "\"" end')" # Zoom a window. `--toggle float` would be nicer, but results # in the window brought back to the wrong place after toggling ctrl + shift + alt - f : yabai -m window --toggle zoom-fullscreen # Move/swap windows ctrl + shift + alt - h : yabai -m window --swap west ctrl + shift + alt - j : yabai -m window --swap south ctrl + shift + alt - k : yabai -m window --swap north ctrl + shift + alt - l : yabai -m window --swap east # Split ctrl + shift + alt + cmd - h : yabai -m window --warp west ctrl + shift + alt + cmd - j : yabai -m window --warp south ctrl + shift + alt + cmd - k : yabai -m window --warp north ctrl + shift + alt + cmd - l : yabai -m window --warp east # Resize window # NOTE: Custom keys can be checked with `skhd --observe` ctrl + shift + alt - a : yabai -m window --resize left:-50:0; yabai -m window --resize right:-50:0 ctrl + shift + alt - s : yabai -m window --resize bottom:0:50; yabai -m window --resize top:0:50 ctrl + shift + alt - w: yabai -m window --resize top:0:-50; yabai -m window --resize bottom:0:-50 ctrl + shift + alt - d : yabai -m window --resize right:50:0; yabai -m window --resize left:50:0 # Move window to other desktop and focus desktop # FIXME: doesn't work with cmd only cmd - 1 : yabai -m window --space 1 cmd - 2 : yabai -m window --space 2; yabai -m space --focus 2 cmd - 3 : yabai -m window --space 3 cmd - 4 : yabai -m window --space 4 cmd - 5 : yabai -m window --space 5 # Move window to display left and right ctrl + shift + alt - r : yabai -m window --display west; yabai -m display --focus west ctrl + shift + alt - u : yabai -m window --display east; yabai -m display --focus east # Revert resized windows to default ctrl + shift + alt - 0 : yabai -m space --balance # Rotate windows clockwise ctrl + shift + alt - y : yabai -m space --rotate 270 # Indicate focus # NOTE: Needs scripting/protection off #ctrl + shift + alt - m : yabai -m window --opacity 0.1 && sleep $(yabai -m config window_opacity_duration) && yabai -m window --opacity 0.0