From 8e284dcefc551454e5c092151c1551bebe535e0d Mon Sep 17 00:00:00 2001 From: Ein Verne Date: Wed, 21 Oct 2020 20:40:39 +0800 Subject: [PATCH] Add yabai configs --- hammerspoon/init.lua | 56 ++++++++++++------- kitty/base16-solarized-dark-256.conf | 43 +++++++++++++++ kitty/kitty.conf | 2 +- skhd/skhdrc | 81 +++++++++++++--------------- yabai/yabairc | 4 +- 5 files changed, 121 insertions(+), 65 deletions(-) create mode 100644 kitty/base16-solarized-dark-256.conf diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index b259797..d972f78 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -84,24 +84,24 @@ local reading_layout = { {"Miwork", nil, right_monitor, hs.layout.top50, nil, nil}, } -hs.hotkey.bind(hyper, "1", function() - hs.application.launchOrFocus('Google Chrome') - hs.application.launchOrFocus('iTerm') - hs.application.launchOrFocus('Miwork') - - hs.layout.apply(reading_layout) -end) +-- hs.hotkey.bind(hyper, "1", function() +-- hs.application.launchOrFocus('Google Chrome') +-- hs.application.launchOrFocus('iTerm') +-- hs.application.launchOrFocus('Miwork') +-- +-- hs.layout.apply(reading_layout) +-- end) local coding_layout = { {"IntelliJ IDEA Ultimate", nil, middle_monitor, hs.layout.maximized, nil, nil}, {"iTerm", nil, left_monitor, hs.layout.maximized, nil, nil}, } -hs.hotkey.bind(hyper, "2", function() - hs.application.launchOrFocus('IntelliJ IDEA') - - hs.layout.apply(coding_layout) -end) +-- hs.hotkey.bind(hyper, "2", function() +-- hs.application.launchOrFocus('IntelliJ IDEA') +-- +-- hs.layout.apply(coding_layout) +-- end) wifiWatcher = nil @@ -206,6 +206,8 @@ else end end + + function reloadConfig() hs.reload() hs.execute("/bin/launchctl kickstart -k \"gui/${UID}/homebrew.mxcl.yabai\"") @@ -244,6 +246,24 @@ for _, v in pairs(hspoon_list) do hs.loadSpoon(v) end +hs.hotkey.bind({}, "F12", function() + local app = hs.application.get("kitty") + if app then + if not app:mainWindow() then + app:selectMenuItem({"kitty", "New OS window"}) + elseif app:isFrontmost() then + app:hide() + else + app:activate() + end + else + hs.application.launchOrFocus("kitty") + app = hs.application.get("kitty") + end + + app:mainWindow():moveToUnit'[100, 80, 0, 0]' +end) + ---------------------------------------------------------------------------------------------------- -- Then we create/register all kinds of modal keybindings environments. ---------------------------------------------------------------------------------------------------- @@ -498,12 +518,12 @@ end ---------------------------------------------------------------------------------------------------- -- Register AClock -if spoon.AClock then - hsaclock_keys = hsaclock_keys or {"alt", "T"} - if string.len(hsaclock_keys[2]) > 0 then - spoon.ModalMgr.supervisor:bind(hsaclock_keys[1], hsaclock_keys[2], "Toggle Floating Clock", function() spoon.AClock:toggleShow() end) - end -end +-- if spoon.AClock then +-- hsaclock_keys = hsaclock_keys or {"alt", "T"} +-- if string.len(hsaclock_keys[2]) > 0 then +-- spoon.ModalMgr.supervisor:bind(hsaclock_keys[1], hsaclock_keys[2], "Toggle Floating Clock", function() spoon.AClock:toggleShow() end) +-- end +-- end -- Register WinRectangle if spoon.WinRectangle then diff --git a/kitty/base16-solarized-dark-256.conf b/kitty/base16-solarized-dark-256.conf new file mode 100644 index 0000000..cdcc683 --- /dev/null +++ b/kitty/base16-solarized-dark-256.conf @@ -0,0 +1,43 @@ +# Base16 Solarized Dark - kitty color config +# Scheme by Ethan Schoonover (modified by aramisgithub) +background #002b36 +foreground #93a1a1 +selection_background #93a1a1 +selection_foreground #002b36 +url_color #839496 +cursor #93a1a1 +active_border_color #657b83 +inactive_border_color #073642 +active_tab_background #002b36 +active_tab_foreground #93a1a1 +inactive_tab_background #073642 +inactive_tab_foreground #839496 +tab_bar_background #073642 + +# normal +color0 #002b36 +color1 #dc322f +color2 #859900 +color3 #b58900 +color4 #268bd2 +color5 #6c71c4 +color6 #2aa198 +color7 #93a1a1 + +# bright +color8 #657b83 +color9 #dc322f +color10 #859900 +color11 #b58900 +color12 #268bd2 +color13 #6c71c4 +color14 #2aa198 +color15 #fdf6e3 + +# extended base16 colors +color16 #cb4b16 +color17 #d33682 +color18 #073642 +color19 #586e75 +color20 #839496 +color21 #eee8d5 diff --git a/kitty/kitty.conf b/kitty/kitty.conf index b5ef4ac..2905d00 100644 --- a/kitty/kitty.conf +++ b/kitty/kitty.conf @@ -1038,7 +1038,7 @@ term xterm-kitty #: hide_window_decorations. # macos_option_as_alt no -macos_option_as_alt yes +# macos_option_as_alt yes #: Use the option key as an alt key. With this set to no, kitty will #: use the macOS native Option+Key = unicode character behavior. This diff --git a/skhd/skhdrc b/skhd/skhdrc index 2485a3b..c86442b 100644 --- a/skhd/skhdrc +++ b/skhd/skhdrc @@ -101,7 +101,7 @@ # 0x2F = Fullstop / > # 0x2C = Slash # open terminal -# cmd - return : /Applications/iTerm.app/Contents/MacOS/iTerm2 --single-instance -d ~ &> /dev/null +cmd - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~ &> /dev/null # close focused window # alt - w : yabai -m window --close @@ -137,10 +137,10 @@ alt + shift - k : yabai -m window --swap north alt + shift - l : yabai -m window --swap east # stack window -alt + ctrl + shift - h : yabai -m window --stack west -alt + ctrl + shift - j : yabai -m window --stack south -alt + ctrl + shift - k : yabai -m window --stack north -alt + ctrl + shift - l : yabai -m window --stack east +# alt + ctrl + shift - h : yabai -m window --stack west +# alt + ctrl + shift - j : yabai -m window --stack south +# alt + ctrl + shift - k : yabai -m window --stack north +# alt + ctrl + shift - l : yabai -m window --stack east # make floating window fill screen, make it float if not already floating ctrl + alt + cmd - t : yabai -m window --toggle float; \ @@ -226,35 +226,34 @@ alt + cmd - w : yabai -m window --resize top:0:-80 alt + cmd - s : yabai -m window --resize right:80:0 # decrease region size -alt + cmd + ctrl - a : yabai -m window --resize left:80:0 -alt + cmd + ctrl - r : yabai -m window --resize bottom:0:-80 -alt + cmd + ctrl - w : yabai -m window --resize top:0:80 -alt + cmd + ctrl - s : yabai -m window --resize right:-80:0 +# alt + cmd + ctrl - a : yabai -m window --resize left:80:0 +# alt + cmd + ctrl - r : yabai -m window --resize bottom:0:-80 +# alt + cmd + ctrl - w : yabai -m window --resize top:0:80 +# alt + cmd + ctrl - s : yabai -m window --resize right:-80:0 # set insertion point for focused container ctrl + alt - h : yabai -m window --insert west -ctrl + alt - m : yabai -m window --insert west -ctrl + alt - n : yabai -m window --insert south -ctrl + alt - e : yabai -m window --insert north -ctrl + alt - i : yabai -m window --insert east +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 +# alt - r : yabai -m space --rotate 90 # mirror tree y-axis -alt + shift - x : yabai -m space --mirror vertical +# alt + shift - x : yabai -m space --mirror vertical # mirror tree x-axis -alt - x : yabai -m space --mirror horizontal +# alt - x : yabai -m space --mirror horizontal # toggle desktop padding -alt - a : yabai -m space --toggle padding +# alt - a : yabai -m space --toggle padding # toggle window fullscreen -alt - f : yabai -m window --toggle fullscreen +# alt - f : yabai -m window --toggle fullscreen # toggle window native fullscreen -shift + alt - f : yabai -m window --toggle native-fullscreen +# shift + alt - f : yabai -m window --toggle native-fullscreen # toggle window zoom alt - z : yabai -m window --toggle zoom-fullscreen @@ -263,40 +262,33 @@ alt - z : yabai -m window --toggle zoom-fullscreen alt - c : yabai -m window --toggle split # toggle window fade -alt - q : yabai -m window --toggle fade +# alt - q : yabai -m window --toggle fade # float / unfloat window and center on screen alt - t : yabai -m window --toggle float;\ yabai -m window --grid 6:6:1:1:4:4 # toggle sticky -alt - s : yabai -m window --toggle sticky +# alt - s : yabai -m window --toggle sticky # toggle border -alt - b : yabai -m window --toggle border +# alt - b : yabai -m window --toggle border # classic pip -alt - p : yabai -m window --toggle float;\ - yabai -m window --toggle sticky;\ - yabai -m window --toggle topmost;\ - yabai -m window --grid 5:5:3:0:2:2 +# alt - p : yabai -m window --toggle float;\ +# yabai -m window --toggle sticky;\ +# yabai -m window --toggle topmost;\ +# yabai -m window --grid 5:5:3:0:2:2 # toggle sticky, float and resize to picture-in-picture size -alt + shift - p : yabai -m window --toggle sticky;\ - yabai -m window --toggle topmost;\ - yabai -m window --toggle border;\ - yabai -m window --toggle pip +# alt + shift - p : yabai -m window --toggle sticky;\ +# yabai -m window --toggle topmost;\ +# yabai -m window --toggle border;\ +# yabai -m window --toggle pip # float next window to be tiled # shift + alt - t : chunkc set window_float_next 1 -# change layout of desktop -ctrl + alt - a : yabai -m space --layout bsp; \ - terminal-notifier -title Yabai -message "Bsp mode activated" -ctrl + alt - r: yabai -m space --layout float; \ - terminal-notifier -title Yabai -message "Float mode activated" -ctrl + alt - s : yabai -m space --layout stack; \ - terminal-notifier -title Yabai -message "Stack mode activated" # ctrl + alt - l : yabai -m space --deserialize ~/.chunkwm_layout # ctrl + alt + cmd - l : yabai -m space --serialize ~/.chunkwm_layout @@ -306,9 +298,9 @@ cmd + shift - 4 -> : yabai -m window --toggle border; sleep 3; yabai -m window - ctrl + cmd + shift - 4 -> : yabai -m window --toggle border; sleep 3; yabai -m window --toggle border; # MPC commands -ctrl + alt + cmd + shift - 0x23 : mpc toggle -ctrl + alt + cmd - 0x2B : mpc prev -ctrl + alt + cmd - 0x2F : mpc next +# ctrl + alt + cmd + shift - 0x23 : mpc toggle +# ctrl + alt + cmd - 0x2B : mpc prev +# ctrl + alt + cmd - 0x2F : mpc next # Reload yabai ctrl + alt + cmd - z : osascript -e 'tell application "Keyboard Maestro Engine" to do script "Hide All Windows"' && \ @@ -334,19 +326,18 @@ ctrl + alt + cmd - c : ids=$(yabai -m query --windows --space | jq -r ".[] | sel alt - 0x2C : yabai -m space --balance # Toggle space windows gap -alt - d : yabai -m space --toggle gap +# alt - d : yabai -m space --toggle gap # Toggle space windows padding -alt - g : yabai -m space --toggle padding +# alt - g : yabai -m space --toggle padding # Task randomizer -ctrl + alt + cmd + shift - d : osascript ~/Library/Scripts/omnifocus-task-randomizer.applescript +# ctrl + alt + cmd + shift - d : osascript ~/Library/Scripts/omnifocus-task-randomizer.applescript # Hyper 1-0 -ctrl + alt + cmd + shift - 1 : /Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge +# ctrl + alt + cmd + shift - 1 : /Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge # change layout of desktop ctrl + alt - a : yabai -m space --layout bsp ctrl + alt - d : yabai -m space --layout float ctrl + alt - s : yabai -m space --layout $(yabai -m query --spaces --space | jq -r 'if .type == "bsp" then "float" else "bsp" end') - diff --git a/yabai/yabairc b/yabai/yabairc index 38b1693..1e76b46 100755 --- a/yabai/yabairc +++ b/yabai/yabairc @@ -48,14 +48,17 @@ yabai -m rule --add label="App Store" app="^App Store$" manage=off yabai -m rule --add label="Calculator" app="^Calculator$" manage=off yabai -m rule --add label="Dash" app="Dash" manage=off yabai -m rule --add label="DataGrip" app="DataGrip" manage=off +yabai -m rule --add label="Dictionary" app="^Dictionary$" manage=off yabai -m rule --add app="^Discord$" space=7 grid=1:1:0:0:1:1 manage=off yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off yabai -m rule --add label="GoldenDict" app="GoldenDict" manage=off +yabai -m rule --add label="kitty" app="kitty" manage=off yabai -m rule --add label="IntelliJ IDEA" app="IntelliJ IDEA" manage=off space=code yabai -m rule --add label="Preview" app="Preview" manage=off yabai -m rule --add label="System Preferences" app="^System Preferences$" manage=off yabai -m rule --add label="SmartGit" app="SmartGit" manage=off space=git yabai -m rule --add label="VirtualBox" app="^VirtualBox$" manage=off +yabai -m rule --add label="Zotero" app="^Zotero$" manage=off @@ -65,5 +68,4 @@ yabai -m signal --add event=window_destroyed action="yabai -m query --windows -- yabai -m signal --add event=window_minimized action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - echo "yabai configuration loaded.."