Skip to content

Instantly share code, notes, and snippets.

@dgrebb
Last active September 22, 2023 21:01
Show Gist options
  • Select an option

  • Save dgrebb/d3ca843c61d9cabfdd30bf89976e454e to your computer and use it in GitHub Desktop.

Select an option

Save dgrebb/d3ca843c61d9cabfdd30bf89976e454e to your computer and use it in GitHub Desktop.
yabai commands
# use these in Keyboard Maestro with an "Execute Shell Script" Action
# cycle forward through spaces on the focused display
id="$(yabai -m query --spaces --display | jq 'sort_by(.index) | reverse | .[map(."has-focus") | index(true) - 1].index')" && yabai -m space --focus "${id}"
# cycle backward through spaces on the focused display
id="$(yabai -m query --spaces --display | jq 'sort_by(.index) | .[map(."has-focus") | index(true) - 1].index')" && yabai -m space --focus "${id}"
# cycle forward to next space across all displays (circularly)
yabai -m space --focus next || yabai -m space --focus first
# cycle backward to previous space across all displays (circularly)
yabai -m space --focus prev || yabai -m space --focus last
# move window to and focus next space
yabai -m window --space next && yabai -m space --focus next || \
yabai -m window --space first && yabai -m space --focus first
# move window to and focus previous space
yabai -m window --space prev
yabai -m space --focus prev
# swap window to next tile
yabai -m window --swap next || yabai -m window --swap first
# swap window to previous tile
yabai -m window --swap prev || yabai -m window --swap last
# overall focused space padding around edges ~95%
yabai -m space --padding abs:10:10:20:20
# increase overall focused space padding
yabai -m space --padding rel:10:10:20:20
# decrease overall focused space padding
yabai -m space --padding rel:-10:-10:-20:-20
# toggle window float on/off
yabai -m window --toggle float
# toggle window opaque/translucent
opacity=$(yabai -m query --windows --window | jq '.opacity'); if (( $(echo "$opacity < 1.0" |bc -l) )); then yabai -m window --opacity 1.0; else yabai -m window --opacity 0.95; fi
# if below 1.0 opacity, increase by 0.05
opacity=$(yabai -m query --windows --window | jq '.opacity'); if (( $(echo "$opacity < 1.0" |bc -l) )); then newpacity=`echo $opacity + 0.05 | bc`; yabai -m window --opacity $newpacity; fi
# if below 1.0 opacity, reduce by 0.05
opacity=$(yabai -m query --windows --window | jq '.opacity'); if (( $(echo "$opacity > 0.0" |bc -l) )); then newpacity=`echo $opacity - 0.05 | bc`; yabai -m window --opacity $newpacity; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment