Skip to content

Instantly share code, notes, and snippets.

@albertsj1
Created May 4, 2023 16:15
Show Gist options
  • Save albertsj1/f60496003789921f5a8c6bbc30cddc2f to your computer and use it in GitHub Desktop.
Save albertsj1/f60496003789921f5a8c6bbc30cddc2f to your computer and use it in GitHub Desktop.
My .yabairc
#!/usr/bin/env bash
. ${HOME}/.config/yabai/lib/constants.sh
# load scripting additions
sudo /usr/local/bin/yabai --load-sa
yabai -m signal --add event=dock_did_restart action="sudo /usr/local/bin/yabai --load-sa"
# Save my order of displays (left to right) to a variable and file
# We use the variable here and the file is to be used by other apps, such as skhd.
${HOME}/bin/yabai_ctl.sh display_initialize &> /dev/null
readarray -d ' ' -t screens < ${Y_ENV_DIR}/displays.txt
PRIMARY_DISPLAY=${screens[3]}
MAX_SPACES=9
yabai -m config external_bar all:32:0 \
layout bsp \
window_border on \
window_border_width $D_WINDOW_BORDER_WIDTH \
normal_window_border_color $D_NORMAL_BORDER_COLOR \
active_window_border_color $D_ACTIVE_BORDER_COLOR \
top_padding $D_WINDOW_PADDING \
bottom_padding $D_WINDOW_PADDING \
left_padding $D_WINDOW_PADDING \
right_padding $D_WINDOW_PADDING \
window_gap $D_WINDOW_PADDING \
auto_balance off \
split_ratio 0.5 \
window_shadow off \
window_animation_duration 0.0 \
window_opacity on \
active_window_opacity 1.0 \
normal_window_opacity 0.9 \
mouse_follows_focus on
# debug_output on
#
# setup spaces
#
for i in $(yabai -m query --spaces | jq ".[] | select((.display == ${PRIMARY_DISPLAY:=1}) and .index > $MAX_SPACES).index"); do
echo yabai -m space --destroy $i
done
function setup_space {
local idx="$1"
local name="$2"
local space=
echo "setup space $idx : $name"
space=$(yabai -m query --spaces --space "$idx")
if [ -z "$space" ]; then
yabai -m space --create
fi
yabai -m space "$idx" --label "$name"
}
setup_space 1 emacs
setup_space 2 web
setup_space 3 outlook
setup_space 4 chime
setup_space 5 firefox
setup_space 6 other
setup_space 7 slack
setup_space 8 kiwi
setup_space 9 term
# move some apps automatically to specific spaces
# Turn off management completely for certain apps
yabai -m rule --add app="(Coherence X|JetBrains Toolbox|VOX|Amazon Client Management Engine (ACME)|Connections|Twilio Authy|Authy Desktop|Plexamp|BetterTouchTool|Cisco AnyConnect|Boom 3D|Calculator|Software Update|Dictionary|VLC|System Preferences|System Settings|zoom.us|Photo Booth|Archive Utility|Python|LibreOffice|App Store|Steam|Alfred|Activity Monitor|Twilio Authy)" manage=off
# Turn off management for other certain app windows
yabai -m rule --add app="Outlook$" title="Calendar" manage=off
#yabai -m rule --add app="Chime$" title="Meeting" manage=off
yabai -m rule --add app="^Firefox$" title="^$" manage=off
yabai -m rule --add app="^Kiwi" title="Calendar" manage=off
yabai -m rule --add app="(iStat Menus.*|Forecast Bar)" manage=off mouse_follows_focus=off layer=above sticky=on
yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off layer=above
yabai -m rule --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off layer=above
yabai -m rule --add label="About This Mac" app="System Information" title="About This Mac" manage=off layer=above
# Move certain apps to dedicated spaces
yabai -m rule --add app="Outlook$" space=^3
yabai -m rule --add app="Chime$" space=^4
#yabai -m rule --add app="^Firefox$" space=^5
yabai -m rule --add app="^Slack$" space=7
yabai -m rule --add app="^Kiwi" space=8
yabai -m rule --add app="^kitty$" space=9
# events
#yabai -m signal --add event=window_created app="^Amazon Chime$" title!="^(Amazon Chime|Mute box)$" action="${HOME}/bin/yabai_signal_commands.sh stack_chime"
yabai -m signal --add event=window_created app="^Amazon Chime$" action="${HOME}/bin/yabai_signal_commands.sh stack_chime"
yabai -m signal --add event=window_created action="sketchybar -m --trigger window_created &> /dev/null"
yabai -m signal --add event=window_destroyed action="sketchybar -m --trigger window_destroyed &> /dev/null"
yabai -m signal --add event=window_focused action="sketchybar -m --trigger window_focus &> /dev/null"
yabai -m signal --add event=display_added action="${HOME}/bin/yabai_ctl.sh display_added &> /dev/null; skhd -r"
yabai -m signal --add event=display_removed action="${HOME}/bin/yabai_ctl.sh display_removed &> /dev/null; skhd -r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment