From a0d7689b1e3c7fd74fab9df1ae74e2a6de62fe9b Mon Sep 17 00:00:00 2001 From: Nicholas Tay Date: Sat, 10 Apr 2021 17:06:11 +1000 Subject: Add basic osx yabai+skhd conf --- .config/aliasrc | 2 + .config/skhd/skhdrc | 95 +++++++++++++++++++++++++++++++++++++++++++++++ .config/yabai/iterm2_open | 13 +++++++ .config/yabai/yabairc | 41 ++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100755 .config/skhd/skhdrc create mode 100755 .config/yabai/iterm2_open create mode 100755 .config/yabai/yabairc diff --git a/.config/aliasrc b/.config/aliasrc index 364df5a..74d6ec4 100644 --- a/.config/aliasrc +++ b/.config/aliasrc @@ -72,3 +72,5 @@ alias cfv="$EDITOR $HOME/.config/nvim/init.vim" alias cfa="$EDITOR $HOME/.config/aliasrc" alias cfg="$EDITOR $HOME/.config/git/config" alias cfi="$EDITOR $HOME/.config/i3/config" +alias cfy="$EDITOR $HOME/.config/yabai/yabairc" +alias cfs="$EDITOR $HOME/.config/skhd/skhdrc" diff --git a/.config/skhd/skhdrc b/.config/skhd/skhdrc new file mode 100755 index 0000000..6b8f24e --- /dev/null +++ b/.config/skhd/skhdrc @@ -0,0 +1,95 @@ +# yabai binds +# Window focus +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 + +# Window swaps +alt + ctrl - h : yabai -m window --swap west +alt + ctrl - j : yabai -m window --swap south +alt + ctrl - k : yabai -m window --swap north +alt + ctrl - l : yabai -m window --swap east + +# Move window absolute +shift + alt - h : yabai -m window --warp west +shift + alt - j : yabai -m window --warp south +shift + alt - k : yabai -m window --warp north +shift + alt - l : yabai -m window --warp east + +# 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}" + +# Workspace focus +alt - 1 : yabai -m space --focus 1 +alt - 2 : yabai -m space --focus 2 +alt - 3 : yabai -m space --focus 3 +alt - 4 : yabai -m space --focus 4 +alt - 5 : yabai -m space --focus 5 +alt - 6 : yabai -m space --focus 6 +alt - 7 : yabai -m space --focus 7 +alt - 8 : yabai -m space --focus 8 +alt - 9 : yabai -m space --focus 9 + +# Send window to workspace +shift + alt - 1 : yabai -m window --space 1 +shift + alt - 2 : yabai -m window --space 2 +shift + alt - 3 : yabai -m window --space 3 +shift + alt - 4 : yabai -m window --space 4 +shift + alt - 5 : yabai -m window --space 5 +shift + alt - 6 : yabai -m window --space 6 +shift + alt - 7 : yabai -m window --space 7 +shift + alt - 8 : yabai -m window --space 8 +shift + alt - 9 : yabai -m window --space 9 + +# Send window, follow focus +shift + ctrl + alt - 1 : yabai -m window --space 1; yabai -m space --focus 1 +shift + ctrl + alt - 2 : yabai -m window --space 2; yabai -m space --focus 2 +shift + ctrl + alt - 3 : yabai -m window --space 3; yabai -m space --focus 3 +shift + ctrl + alt - 4 : yabai -m window --space 4; yabai -m space --focus 4 +shift + ctrl + alt - 5 : yabai -m window --space 5; yabai -m space --focus 5 +shift + ctrl + alt - 6 : yabai -m window --space 6; yabai -m space --focus 6 +shift + ctrl + alt - 7 : yabai -m window --space 7; yabai -m space --focus 7 +shift + ctrl + alt - 8 : yabai -m window --space 8; yabai -m space --focus 8 +shift + ctrl + alt - 9 : yabai -m window --space 9; yabai -m space --focus 9 + +# Resize +cmd + alt - h : yabai -m window --resize left:-20:0 +cmd + alt - j : yabai -m window --resize top:0:20 +cmd + alt - k : yabai -m window --resize top:0:-20 +cmd + alt - l : yabai -m window --resize left:20:0 + +# Insertion point +ctrl + shift - h : yabai -m window --insert west +ctrl + shift - j : yabai -m window --insert south +ctrl + shift - k : yabai -m window --insert north +ctrl + shift - l : yabai -m window --insert east + +# Layout +shift + alt - t : yabai -m space --layout float +alt - t : yabai -m space --layout bsp + +# Float +alt + shift - space : yabai -m window --toggle float + +# toggle sticky(+float), topmost, picture-in-picture +alt - p : yabai -m window --toggle sticky;\ + yabai -m window --toggle topmost;\ + yabai -m window --toggle pip + +# Reload +ctrl + alt + cmd - r : launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai" + +# Close window +alt + shift - q : yabai -m window --close + +# Fullscreen +alt - f : yabai -m window --toggle zoom-fullscreen +shift + alt - f : yabai -m window --toggle native-fullscreen + +# Programs +alt - return : $HOME/.config/yabai/iterm2_open +alt - w : /Applications/Firefox.app/Contents/MacOS/firefox diff --git a/.config/yabai/iterm2_open b/.config/yabai/iterm2_open new file mode 100755 index 0000000..fd9efe4 --- /dev/null +++ b/.config/yabai/iterm2_open @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# Detects if iTerm2 is running +if ! pgrep -f "iTerm" > /dev/null; then + open -a "/Applications/iTerm.app" +else + # Create a new window + if ! osascript -e 'tell application "iTerm2" to create window with default profile' > /dev/null; then + # Get pids for any app with "iTerm" and kill + for i in $(pgrep -f "iTerm"); do kill -15 "$i"; done + open -a "/Applications/iTerm.app" + fi +fi diff --git a/.config/yabai/yabairc b/.config/yabai/yabairc new file mode 100755 index 0000000..ed07971 --- /dev/null +++ b/.config/yabai/yabairc @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +yabai -m config mouse_follows_focus on +yabai -m config focus_follows_mouse autofocus + +# Spawn right/bottom +yabai -m config window_placement second_child + +yabai -m config window_opacity off +# Unfocused 90% opacity +yabai -m config active_window_opacity 1.0 +yabai -m config normal_window_opacity 0.9 + +# Borders +yabai -m config window_border on +yabai -m config window_border_width 3 +yabai -m config active_window_border_color 0xff775759 +yabai -m config normal_window_border_color 0xff555555 +yabai -m config insert_feedback_color 0xffd75f5f + +# Mouse stuff +yabai -m config mouse_modifier alt +yabai -m config mouse_action1 move +yabai -m config mouse_action2 resize +yabai -m config mouse_drop_action swap + +# Layout +yabai -m config layout bsp +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 + +# App rules +yabai -m rule --add app="^System Preferences$" manage=off +yabai -m rule --add app="^Calculator$" manage=off +yabai -m rule --add app="^MacPass$" manage=off +yabai -m rule --add app="^Firefox$" title="^Opening .*$" manage=off + +echo "yabai configuration loaded.." -- cgit