Skip to content

Commit

Permalink
feat: add yabai
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezcasas committed Oct 1, 2023
1 parent f061695 commit a812db3
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 2 deletions.
278 changes: 276 additions & 2 deletions os/mac/karabiner-elements/karabiner.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,280 @@
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Focus windows",
"manipulators" : [ {
"from" : {
"key_code" : "j",
"modifiers" : {
"mandatory" : [ "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --focus south"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "k",
"modifiers" : {
"mandatory" : [ "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --focus north"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "h",
"modifiers" : {
"mandatory" : [ "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --focus west"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "l",
"modifiers" : {
"mandatory" : [ "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --focus east"
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Focus displays",
"manipulators" : [ {
"from" : {
"key_code" : "s",
"modifiers" : {
"mandatory" : [ "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m display --focus west"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "g",
"modifiers" : {
"mandatory" : [ "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m display --focus east"
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Modify layout",
"manipulators" : [ {
"from" : {
"key_code" : "r",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m space --rotate 270"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "y",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m space --mirror y-axis"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "x",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m space --mirror x-axis"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "t",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --toggle float --grid 4:4:1:1:2:2"
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Modify window size",
"manipulators" : [ {
"from" : {
"key_code" : "f",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --toggle zoom-fullscreen"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "e",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m space --balance"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "d",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m space --toggle show-desktop"
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Swap window",
"manipulators" : [ {
"from" : {
"key_code" : "j",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --swap south"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "k",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --swap north"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "h",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --swap west"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "l",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --swap east"
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Move window and split",
"manipulators" : [ {
"from" : {
"key_code" : "j",
"modifiers" : {
"mandatory" : [ "left_control", "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --warp south"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "k",
"modifiers" : {
"mandatory" : [ "left_control", "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --warp north"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "h",
"modifiers" : {
"mandatory" : [ "left_control", "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --warp west"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "l",
"modifiers" : {
"mandatory" : [ "left_control", "left_option" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --warp east"
} ],
"type" : "basic"
} ]
}, {
"description" : "[yabai] Move window to another display",
"manipulators" : [ {
"from" : {
"key_code" : "s",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --display west; /opt/homebrew/bin/yabai -m display --focus west;"
} ],
"type" : "basic"
}, {
"from" : {
"key_code" : "g",
"modifiers" : {
"mandatory" : [ "left_option", "left_shift" ]
}
},
"to" : [ {
"shell_command" : "/opt/homebrew/bin/yabai -m window --display east; /opt/homebrew/bin/yabai -m display --focus east;"
} ],
"type" : "basic"
} ]
}, {
"description" : "[chrome] Show recent tabs",
"manipulators" : [ {
Expand Down Expand Up @@ -1874,7 +2148,7 @@
"product_id" : 64023,
"vendor_id" : 9639
},
"ignore" : true,
"ignore" : false,
"manipulate_caps_lock_led" : false,
"simple_modifications" : [ ],
"treat_as_built_in_keyboard" : false
Expand All @@ -1900,7 +2174,7 @@
"product_id" : 45108,
"vendor_id" : 1133
},
"ignore" : true,
"ignore" : false,
"manipulate_caps_lock_led" : false,
"simple_modifications" : [ ],
"treat_as_built_in_keyboard" : false
Expand Down
38 changes: 38 additions & 0 deletions os/mac/karabiner-goku/karabiner.edn
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,44 @@
{:des "[script] Open common folders"
:rules [[:!CTgrave_accent_and_tilde "$HOME/.dotfiles/bin/sdot utils open_common"]]}

;; ------------ Yabai ------------
{:des "[yabai] Focus windows"
:rules [[:!Oj "/opt/homebrew/bin/yabai -m window --focus south"]
[:!Ok "/opt/homebrew/bin/yabai -m window --focus north"]
[:!Oh "/opt/homebrew/bin/yabai -m window --focus west"]
[:!Ol "/opt/homebrew/bin/yabai -m window --focus east"]]}

{:des "[yabai] Focus displays"
:rules [[:!Os "/opt/homebrew/bin/yabai -m display --focus west"]
[:!Og "/opt/homebrew/bin/yabai -m display --focus east"]]}

{:des "[yabai] Modify layout"
:rules [[:!SOr "/opt/homebrew/bin/yabai -m space --rotate 270"]
[:!SOy "/opt/homebrew/bin/yabai -m space --mirror y-axis"]
[:!SOx "/opt/homebrew/bin/yabai -m space --mirror x-axis"]
[:!SOt "/opt/homebrew/bin/yabai -m window --toggle float --grid 4:4:1:1:2:2"]]}

{:des "[yabai] Modify window size"
:rules [[:!SOf "/opt/homebrew/bin/yabai -m window --toggle zoom-fullscreen"]
[:!SOe "/opt/homebrew/bin/yabai -m space --balance"]
[:!SOd "/opt/homebrew/bin/yabai -m space --toggle show-desktop"]]}

{:des "[yabai] Swap window"
:rules [[:!SOj "/opt/homebrew/bin/yabai -m window --swap south"]
[:!SOk "/opt/homebrew/bin/yabai -m window --swap north"]
[:!SOh "/opt/homebrew/bin/yabai -m window --swap west"]
[:!SOl "/opt/homebrew/bin/yabai -m window --swap east"]]}

{:des "[yabai] Move window and split"
:rules [[:!TOj "/opt/homebrew/bin/yabai -m window --warp south"]
[:!TOk "/opt/homebrew/bin/yabai -m window --warp north"]
[:!TOh "/opt/homebrew/bin/yabai -m window --warp west"]
[:!TOl "/opt/homebrew/bin/yabai -m window --warp east"]]}

{:des "[yabai] Move window to another display"
:rules [[:!SOs "/opt/homebrew/bin/yabai -m window --display west; /opt/homebrew/bin/yabai -m display --focus west;"]
[:!SOg "/opt/homebrew/bin/yabai -m window --display east; /opt/homebrew/bin/yabai -m display --focus east;"]]}

;; ------------ Application specific ------------
{:des "[chrome] Show recent tabs"
:rules [:Chrome [:show-recent :!CTO1]]}
Expand Down
25 changes: 25 additions & 0 deletions os/mac/yabai/yabairc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# General config
yabai -m config layout bsp
yabai -m config window_placement second_child
yabai -m config auto_balance on

# Mouse
yabai -m config focus_follows_mouse autoraise
yabai -m config mouse_follows_focus on

yabai -m config mouse_modifier alt
yabai -m config mouse_action1 move
yabai -m config mouse_action2 resize
yabai -m mouse_drop_action swap

# Padding
yabai -m config top_padding 10
yabai -m config bottom_padding 10
yabai -m config left_padding 10
yabai -m config right_padding 10
yabai -m config window_gap 10

# Disable yabai for some apps
yabai -m rule --add app="^System Settings$" manage=off
yabai -m rule --add app="^Activity Monitor$" manage=off
yabai -m rule --add app="^Karabiner-Elements$" manage=off
1 change: 1 addition & 0 deletions symlinks/conf.macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
~/.config/karabiner.edn: os/mac/karabiner-goku/karabiner.edn
~/.config/karabiner: os/mac/karabiner-elements
~/.config/linearmouse: os/mac/linearmouse
~/.config/yabai: os/mac/yabai
~/.dotly: os/mac/.dotly
~/.skhdrc: os/mac/skhd/.skhdrc
~/.tmux.conf: os/mac/.tmux.conf
Expand Down

0 comments on commit a812db3

Please sign in to comment.