Skip to content

Instantly share code, notes, and snippets.

@TomFaulkner
Last active February 27, 2024 23:38
Show Gist options
  • Star 38 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save TomFaulkner/5531bde4f2955c08bcd07d6e308f6d59 to your computer and use it in GitHub Desktop.
Save TomFaulkner/5531bde4f2955c08bcd07d6e308f6d59 to your computer and use it in GitHub Desktop.
Yabai configs
# open terminal
# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2
# focus 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
# swap window
shift + alt - h : yabai -m window --swap west
shift + alt - j : yabai -m window --swap south
shift + alt - k : yabai -m window --swap north
shift + alt - l : yabai -m window --swap east
# move window
shift + cmd - h : yabai -m window --warp west
shift + cmd - j : yabai -m window --warp south
shift + cmd - k : yabai -m window --warp north
shift + cmd - l : yabai -m window --warp east
# balance size of windows
shift + alt - 0 : yabai -m space --balance
# make floating window fill screen
shift + alt - up : yabai -m window --grid 1:1:0:0:1:1
# make floating window fill left-half of screen
shift + alt - left : yabai -m window --grid 1:2:0:0:1:1
# make floating window fill right-half of screen
shift + alt - right : yabai -m window --grid 1:2:1:0:1:1
# create desktop, move window and follow focus - uses jq for parsing json (brew install jq)
shift + cmd - n : yabai -m space --create && \
index="$(yabai -m query --spaces --display | jq 'map(select(."native-fullscreen" == 0))[-1].index')" && \
yabai -m window --space "${index}" && \
yabai -m space --focus "${index}"
# create desktop and follow focus - uses jq for parsing json (brew install jq)
cmd + alt - n : yabai -m space --create && \
index="$(yabai -m query --spaces --display | jq 'map(select(."native-fullscreen" == 0))[-1].index')" && \
yabai -m space --focus "${index}"
# destroy desktop
cmd + alt - w : yabai -m space --destroy
# fast focus desktop
cmd + alt - x : yabai -m space --focus recent
cmd + alt - z : yabai -m space --focus prev
cmd + alt - c : yabai -m space --focus next
cmd + alt - 1 : yabai -m space --focus 1
cmd + alt - 2 : yabai -m space --focus 2
cmd + alt - 3 : yabai -m space --focus 3
cmd + alt - 4 : yabai -m space --focus 4
cmd + alt - 5 : yabai -m space --focus 5
cmd + alt - 6 : yabai -m space --focus 6
cmd + alt - 7 : yabai -m space --focus 7
cmd + alt - 8 : yabai -m space --focus 8
cmd + alt - 9 : yabai -m space --focus 9
cmd + alt - 0 : yabai -m space --focus 10
# send window to desktop and follow focus
shift + cmd - x : yabai -m window --space recent; yabai -m space --focus recent
shift + cmd - z : yabai -m window --space prev; yabai -m space --focus prev
shift + cmd - c : yabai -m window --space next; yabai -m space --focus next
shift + cmd - 1 : yabai -m window --space 1; yabai -m space --focus 1
shift + cmd - 2 : yabai -m window --space 2; yabai -m space --focus 2
shift + cmd - 3 : yabai -m window --space 3; yabai -m space --focus 3
shift + cmd - 4 : yabai -m window --space 4; yabai -m space --focus 4
shift + cmd - 5 : yabai -m window --space 5; yabai -m space --focus 5
shift + cmd - 6 : yabai -m window --space 6; yabai -m space --focus 6
shift + cmd - 7 : yabai -m window --space 7; yabai -m space --focus 7
shift + cmd - 8 : yabai -m window --space 8; yabai -m space --focus 8
shift + cmd - 9 : yabai -m window --space 9; yabai -m space --focus 9
shift + cmd - 0 : yabai -m window --space 10; yabai -m space --focus 10
# focus monitor
ctrl + alt - x : yabai -m display --focus recent
ctrl + alt - z : yabai -m display --focus prev
ctrl + alt - c : yabai -m display --focus next
ctrl + alt - 1 : yabai -m display --focus 1
ctrl + alt - 2 : yabai -m display --focus 2
ctrl + alt - 3 : yabai -m display --focus 3
# send window to monitor and follow focus
ctrl + cmd - x : yabai -m window --display recent; yabai -m display --focus recent
ctrl + cmd - z : yabai -m window --display prev; yabai -m display --focus prev
ctrl + cmd - c : yabai -m window --display next; yabai -m display --focus next
ctrl + cmd - 1 : yabai -m window --display 1; yabai -m display --focus 1
ctrl + cmd - 2 : yabai -m window --display 2; yabai -m display --focus 2
ctrl + cmd - 3 : yabai -m window --display 3; yabai -m display --focus 3
# move window
shift + ctrl - a : yabai -m window --move rel:-20:0
shift + ctrl - s : yabai -m window --move rel:0:20
shift + ctrl - w : yabai -m window --move rel:0:-20
shift + ctrl - d : yabai -m window --move rel:20:0
# increase window size
shift + alt - a : yabai -m window --resize left:-20:0
shift + alt - s : yabai -m window --resize bottom:0:20
shift + alt - w : yabai -m window --resize top:0:-20
shift + alt - d : yabai -m window --resize right:20:0
# decrease window size
shift + cmd - a : yabai -m window --resize left:20:0
shift + cmd - s : yabai -m window --resize bottom:0:-20
shift + cmd - w : yabai -m window --resize top:0:20
shift + cmd - d : yabai -m window --resize right:-20:0
# set insertion point in focused container
ctrl + alt - h : yabai -m window --insert west
ctrl + alt - j : yabai -m window --insert south
ctrl + alt - k : yabai -m window --insert north
ctrl + alt - l : yabai -m window --insert east
# rotate tree
alt - r : yabai -m space --rotate 90
# mirror tree y-axis
alt - y : yabai -m space --mirror y-axis
# mirror tree x-axis
alt - x : yabai -m space --mirror x-axis
# toggle desktop offset
alt - a : yabai -m space --toggle padding; yabai -m space --toggle gap
# toggle window parent zoom
alt - d : yabai -m window --toggle zoom-parent
# toggle window fullscreen zoom
alt - f : yabai -m window --toggle zoom-fullscreen
# toggle window native fullscreen
shift + alt - f : yabai -m window --toggle native-fullscreen
# toggle window border
shift + alt - b : yabai -m window --toggle border
# toggle window split type
alt - e : yabai -m window --toggle split
# float / unfloat window and center on screen
alt - t : yabai -m window --toggle float;\
yabai -m window --grid 4:4:1:1:2:2
# toggle sticky (show on all spaces)
alt - s : yabai -m window --toggle sticky
# toggle topmost (keep above other windows)
alt - o : yabai -m window --toggle topmost
# toggle sticky, topmost and resize to picture-in-picture size
alt - p : yabai -m window --toggle sticky;\
yabai -m window --toggle topmost;\
yabai -m window --grid 5:5:4:0:1:1
# change layout of desktop
ctrl + alt - a : yabai -m space --layout bsp
ctrl + alt - d : yabai -m space --layout float
command: "/usr/local/bin/yabai -m query --spaces"
refreshFrequency: 3000
removeDuplicates: (ar) ->
if ar.length == 0
return []
res = {}
res[ar[key]] = ar[key] for key in [0..ar.length-1]
value for key, value of res
generateIcons: (spaces) ->
displays = @removeDuplicates((space['display'] for space in spaces))
iconString = ""
for display in displays
for space in spaces when space['display'] == display
iconString += "<li id=\"desktop#{space['index']}\">#{space['index']}</li>"
if display < displays.length
iconString += "<li>—</li>"
return iconString
render: (output) ->
spaces = JSON.parse(output)
htmlString = """
<div class="spaces-container" data-count="#{spaces.length}">
<ul>
#{@generateIcons(spaces)}
</ul>
</div>
"""
style: """
position: relative
margin-top: 7px
font: 14px "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif
color: #aaa
font-weight: 700
ul
list-style: none
margin: 0 0 0 1em
padding: 0
li
display: inline-block
text-align: center
width: 1em
margin: 0 0.5em
li.visible
color: #ededed
border-bottom: 2px solid #ededed
"""
update: (output, domEl) ->
spaces = JSON.parse(output)
if ($(domEl).find('.spaces-container').attr('data-count') != spaces.length.toString())
$(domEl).find('.spaces-container').attr('data-count', "#{spaces.length}")
$(domEl).find('ul').html(@generateIcons(spaces))
else
$(domEl).find('li.visible').removeClass('visible')
for space in spaces when space['visible'] == 1
$(domEl).find("li#desktop#{space['index']}").addClass('visible')

This is my current (as of 4/30/2020) Yabai and skhdrc config as well as the Ubersicht (http://tracesof.net/uebersicht/) widget I use rather than the Yabai status bar. I went this route rather than the built-in status bar because I didn't like how Yabai as of 2.0.1 handled multiple monitors in the status bar.

Nothing is too far from defaults here, and the spaces.coffee was something I found linked in an issue on Yabai's github page.

#!/usr/bin/env sh
# bar settings
yabai -m config status_bar off
yabai -m config status_bar_text_font "Helvetica Neue:Bold:12.0"
yabai -m config status_bar_icon_font "FontAwesome:Regular:12.0"
yabai -m config status_bar_background_color 0xff202020
yabai -m config status_bar_foreground_color 0xffa8a8a8
yabai -m config status_bar_space_icon_strip I II III IV V VI VII VIII IX X
yabai -m config status_bar_power_icon_strip  
yabai -m config status_bar_space_icon 
yabai -m config status_bar_clock_icon 
# global settings
yabai -m config mouse_follows_focus on
yabai -m config focus_follows_mouse off
yabai -m config window_placement second_child
yabai -m config window_topmost off
yabai -m config window_opacity off
yabai -m config window_opacity_duration 0.0
yabai -m config window_shadow on
yabai -m config window_border off
yabai -m config window_border_width 4
yabai -m config active_window_border_color 0xff775759
yabai -m config normal_window_border_color 0xff505050
yabai -m config insert_window_border_color 0xffd75f5f
yabai -m config active_window_opacity 1.0
yabai -m config normal_window_opacity 0.90
yabai -m config split_ratio 0.50
yabai -m config auto_balance off
yabai -m config mouse_modifier fn
yabai -m config mouse_action1 move
yabai -m config mouse_action2 resize
# general space settings
yabai -m config layout bsp
yabai -m config top_padding 32
yabai -m config bottom_padding 10
yabai -m config left_padding 10
yabai -m config right_padding 10
yabai -m config window_gap 5
echo "yabai configuration loaded.."
@emninger
Copy link

emninger commented Jun 13, 2020

First of all, thanks for your very smart configs!

Then I wanted to ask you 2 question:

Is the built-in status_bar still available in the actual yabai? I can't get it to work at all and i do not find any referring to it in the wiki or "man yabai" ... (?)

How would i put the list of workspaces and monitors in your java snippet to the ground? (Sorry for the dumb question, but i'm only "accidentally" in this mac context and not familiar with java scripting, since the macbok air i got by chance is - actually - not useable under linux). My target is to get yabai and the short cuts as close as possible to the i3 setup i have under arch linux).

Thanks in advance for your understanding.

@TomFaulkner
Copy link
Author

I don't know if Yabai still has a functioning status bar. I haven't used their status bar since I first tried it. As for the status.coffee file, I didn't mention how it was used in the readme. It is a widget for Ubersicht. http://tracesof.net/uebersicht/

I feel your pain in having to use a Mac and preferring Linux.

@emninger
Copy link

emninger commented Jun 15, 2020

Thank you for your comment! Oh, there are some fine things with this MacBook Air: battery autonomy e.g. as well as the quality of display. But for the programs etc??? Bah, i understand better now, how strong is arch :) To help me out, i make heavy use of homebrew (unsure if, eventually, macports would be better (?) ).

Yep, i already got the connection with Übersicht and also found out, how to put it on the bottom I changed 2 lines, as follows:
style: """ position: absolute bottom: 0

That worked for me. I still have to find out, how to configure battery status and cpu load and how to put that on the right bottom. Then, the "panel" would be rather similar to those (built-in!) i use with i3. Sure, having something like conky would make things much easier ... ;) But there is something strange with Übersicht: When started automatically on login, it does NOT display the spaces. I have to quit and to restart. I'd presume, there is a timing problem during autostart, but i don't know how to retard the autostart (in linux, normally you have the "sleep x seconds" statement, but in MacOS?).

I also tried to use skhd as a program starter (like either i3 or bspwm via sxkd do) but i discovered that creates many problems: chromium for example, started by a shortcut of skhd crashes any time the webcam or micro is called. I'm not a coder, but that's repeatable.

But oh, it's already something i have ... ;)

Thanks again and cheers!

@TomFaulkner
Copy link
Author

But there is something strange with Übersicht: When started automatically on login, it does NOT display the spaces. I have to quit and to restart. I'd presume, there is a timing problem during autostart, but i don't know how to retard the autostart (in linux, normally you have the "sleep x seconds" statement, but in MacOS?).

I had the same issue. I am not currently using it at all, as after the OS crashed it no longer talks to yabai at all for some reason. (That crash also broke yabai switching displays, so for now I am hitting control left/right.) I also cut back to a single monitor on the mac and am using a Linux desktop for my other displays, so I don't run as much on the work Mac.

I also tried to use skhd as a program starter (like either i3 or bspwm via sxkd do) but i discovered that creates many problems: chromium for example, started by a shortcut of skhd crashes any time the webcam or micro is called. I'm not a coder, but that's repeatable.

No clue on that one. Unfortunately OS X does a lot of weird things that break the workflow of typical Linux users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment