refactor(yabai,skhd): remove clutter, use meh/hyper shortcuts for definitions

This commit is contained in:
Oliver Ladner 2025-07-10 12:55:04 +02:00
commit 358c24a3da
2 changed files with 43 additions and 40 deletions

View file

@ -4,6 +4,9 @@
# the Ctrl+Shift+Alt key combo which helps here to have unique skhd shortcuts
# that don't clash with macOS/Neovim/...
# meh = shift + alt + ctrl
# hyper = cmd + shift + alt + ctrl
# Focus a window
alt - h : yabai -m window --focus west
alt - j : yabai -m window --focus south
@ -11,54 +14,53 @@ 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')"
meh - 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')"
meh - 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')"
meh - 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')"
meh - 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')"
meh - 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
meh - 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
meh - h : yabai -m window --swap west
meh - j : yabai -m window --swap south
meh - k : yabai -m window --swap north
meh - 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
hyper - h : yabai -m window --warp west
hyper - j : yabai -m window --warp south
hyper - k : yabai -m window --warp north
hyper - 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
meh - a : yabai -m window --resize left:-50:0; yabai -m window --resize right:-50:0
meh - s : yabai -m window --resize bottom:0:50; yabai -m window --resize top:0:50
meh - w: yabai -m window --resize top:0:-50; yabai -m window --resize bottom:0:-50
meh - 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
# FIXME: doesn't work, maybe needs SIP off?
hyper - 1 : yabai -m window --space 1
hyper - 2 : yabai -m window --space 2
hyper - 3 : yabai -m window --space 3
hyper - 4 : yabai -m window --space 4
hyper - 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
meh - r : yabai -m window --display west; yabai -m display --focus west
meh - u : yabai -m window --display east; yabai -m display --focus east
# Revert resized windows to default
ctrl + shift + alt - 0 : yabai -m space --balance
meh - 0 : yabai -m space --balance
# Rotate windows clockwise
ctrl + shift + alt - y : yabai -m space --rotate 270
meh - 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
#hyper - o: yabai -m window --opacity 0.1 && sleep $(yabai -m config window_opacity_duration) && yabai -m window --opacity 0.0

View file

@ -4,6 +4,8 @@
# /tmp/yabai_$USER.err.log
# /tmp/yabai_$USER.out.log
yabai -m window --opacity 0.1 && sleep $(yabai -m config window_opacity_duration) && yabai -m window --opacity 0.0
yabai -m config layout bsp
yabai -m config window_placement second_child
@ -28,17 +30,16 @@ yabai -m config mouse_modifier ctrl
#yabai -m config --space 2 window_gap
# Floating (unmanaged) apps
yabai -m rule --add app=".*" sub-layer=normal
#yabai -m rule --add app=".*" sub-layer=normal
yabai -m rule --add app="^Calculator$" manage=off
yabai -m rule --add app"^=VLC$" manage=off
yabai -m rule --add app="^VLC$" manage=off
yabai -m rule --add app="^System Settings$" manage=off
# Launch borders
# https://github.com/FelixKratz/JankyBorders/issues/37#issuecomment-1871262622
#borders order=above active_color=0xff007777 inactive_color=0xff004444 width=8.0 style=square &
#borders order=above active_color=0xffffd700 inactive_color=0xff004444 width=8.0 style=square &
#borders order=above active_color=0xffffd700 inactive_color=0xff897400 width=8.0 style=square &
#borders order=above active_color=0xffffd700 background_color=0xee897400 width=8.0 style=square blacklist="firefox" &
#borders order=above active_color=0xffffd700 background_color=0xee897400 width=8.0 style=square &
# yabai -m rule --add app="^Firefox$" space=1
yabai -m rule --add app="^Ghostty$" space=2
yabai -m rule --add app="^Things$" space=3
yabai -m rule --add app="^Calendar$" space=3
yabai -m rule --add app="^Microsoft Teams$" space=5
yabai -m rule --add app="^Slack$" space=5
yabai -m rule --add app="^Signal$" space=5
echo "$(date) yabai config $0 loaded"