Skip to content

Instantly share code, notes, and snippets.

@cbrgm
Created June 16, 2021 16:32
Show Gist options
  • Save cbrgm/ac1a0165f186eaec0bd804bd6f91160c to your computer and use it in GitHub Desktop.
Save cbrgm/ac1a0165f186eaec0bd804bd6f91160c to your computer and use it in GitHub Desktop.

Revisions

  1. cbrgm created this gist Jun 16, 2021.
    154 changes: 154 additions & 0 deletions .skhdrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,154 @@
    ####### Shortcut Hotkeys #############
    # open terminal
    alt - return : open -n /Applications/Alacritty.app

    # restart Yabi, SpaceBar, and SKHD
    alt + shift - r : \
    launchctl kickstart -k "gui/${UID}/homebrew.mxcl.yabai"; \
    skhd --reload


    ####### Application Blacklists #############
    #.blacklist [
    # "IntelliJ IDEA"
    #]


    ####### Window Management Hotkeys #############
    # change 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
    # (alt) change focus (using arrow keys)
    alt - left : yabai -m window --focus west
    alt - down : yabai -m window --focus south
    alt - up : yabai -m window --focus north
    alt - right : yabai -m window --focus east

    # shift window in current workspace
    alt + shift - h : yabai -m window --swap west || $(yabai -m window --display west; yabai -m display --focus west)
    alt + shift - j : yabai -m window --swap south || $(yabai -m window --display south; yabai -m display --focus south)
    alt + shift - k : yabai -m window --swap north || $(yabai -m window --display north; yabai -m display --focus north)
    alt + shift - l : yabai -m window --swap east || $(yabai -m window --display east; yabai -m display --focus east)
    # alternatively, use the arrow keys
    alt + shift - left : yabai -m window --swap west || $(yabai -m window --display west; yabai -m display --focus west)
    alt + shift - down : yabai -m window --swap south || $(yabai -m window --display south; yabai -m display --focus south)
    alt + shift - up : yabai -m window --swap north || $(yabai -m window --display north; yabai -m display --focus north)
    alt + shift - right : yabai -m window --swap east || $(yabai -m window --display east; yabai -m display --focus east)

    # set insertion point in focused container
    alt + ctrl - h : yabai -m window --insert west
    alt + ctrl - j : yabai -m window --insert south
    alt + ctrl - k : yabai -m window --insert north
    alt + ctrl - l : yabai -m window --insert east
    # (alt) set insertion point in focused container using arrows
    alt + ctrl - left : yabai -m window --insert west
    alt + ctrl - down : yabai -m window --insert south
    alt + ctrl - up : yabai -m window --insert north
    alt + ctrl - right : yabai -m window --insert east

    # go back to previous workspace (kind of like back_and_forth in i3)
    alt - b : yabai -m space --focus recent

    # move focused window to previous workspace
    alt + shift - b : yabai -m window --space recent; \
    yabai -m space --focus recent

    # navigate workspaces next / previous using arrow keys
    # cmd - left : yabai -m space --focus prev
    # cmd - right : yabai -m space --focus next

    # move focused window to next/prev workspace
    alt + shift - 1 : yabai -m window --space 1
    alt + shift - 2 : yabai -m window --space 2
    alt + shift - 3 : yabai -m window --space 3
    alt + shift - 4 : yabai -m window --space 4
    alt + shift - 5 : yabai -m window --space 5
    alt + shift - 6 : yabai -m window --space 6
    alt + shift - 7 : yabai -m window --space 7
    alt + shift - 8 : yabai -m window --space 8
    alt + shift - 9 : yabai -m window --space 9
    #alt + shift - 0 : yabai -m window --space 10

    # # mirror tree y-axis
    alt + shift - y : yabai -m space --mirror y-axis

    # # mirror tree x-axis
    alt + shift - x : yabai -m space --mirror x-axis

    # balance size of windows
    alt + shift - 0 : yabai -m space --balance

    # increase window size
    alt + shift - a : yabai -m window --resize left:-20:0
    alt + shift - s : yabai -m window --resize bottom:0:20
    alt + shift - w : yabai -m window --resize top:0:-20
    alt + shift - d : yabai -m window --resize right:20:0

    # decrease window size
    cmd + shift - a : yabai -m window --resize left:20:0
    cmd + shift - s : yabai -m window --resize bottom:0:-20
    cmd + shift - w : yabai -m window --resize top:0:20
    cmd + shift - d : yabai -m window --resize right:-20:0

    # change layout of desktop
    alt - e : yabai -m space --layout bsp
    alt - s : yabai -m space --layout float

    # float / unfloat window and center on screen
    #alt - t : yabai -m window --toggle float;\
    # yabai -m window --grid 4:4:1:1:2:2
    # float / unfloat window and leave in its current location
    alt + shift - space : yabai -m window --toggle float
    #alt + ctrl - space : yabai -m window --toggle float

    # make floating window fill screen
    alt + cmd - up : yabai -m window --grid 1:1:0:0:1:1

    # make floating window fill left-half of screen
    alt + cmd - left : yabai -m window --grid 1:2:0:0:1:1

    # make floating window fill right-half of screen
    alt + cmd - right : yabai -m window --grid 1:2:1:0:1:1

    # create desktop, move window and follow focus
    alt + 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, move window and stay in current workspace
    alt + shift - n : yabai -m space --create;\
    index="$(yabai -m query --spaces --display | jq 'map(select(."native-fullscreen" == 0))[-1].index')"; \
    yabai -m window --space "${index}"

    # create desktop and follow focus
    # Note: script fails when workspace is empty due to Yabai not reporting the workspace (bug?)
    # best to use the create + move window command instead of creating a blank window
    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
    alt + cmd - w : yabai -m space --destroy

    # close focused window
    alt - w : yabai -m window --close

    # toggle sticky
    alt + ctrl - s : yabai -m window --toggle sticky

    # enter fullscreen mode for the focused container
    alt - f : yabai -m window --toggle zoom-fullscreen

    # toggle window native fullscreen
    alt + shift - f : yabai -m window --toggle native-fullscreen

    # focus monitor
    alt + ctrl - x : yabai -m display --focus recent
    alt + ctrl - z : yabai -m display --focus prev
    alt + ctrl - c : yabai -m display --focus next
    alt + ctrl - 1 : yabai -m display --focus 1
    alt + ctrl - 2 : yabai -m display --focus 2
    alt + ctrl - 3 : yabai -m display --focus 3
    74 changes: 74 additions & 0 deletions .yabairc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,74 @@
    #!/usr/bin/env sh

    # the scripting-addition must be loaded manually if
    # you are running yabai on macOS Big Sur. Uncomment
    # the following line to have the injection performed
    # when the config is executed during startup.
    #
    # for this to work you must configure sudo such that
    # it will be able to run the command without password
    #
    # see this wiki page for information:
    # - https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)
    #
    # sudo yabai --load-sa
    # yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"

    #!/usr/bin/env sh

    # global settings
    yabai -m config mouse_follows_focus off
    yabai -m config focus_follows_mouse autofocus

    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 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 active_window_border_color 0xff775759
    yabai -m config normal_window_border_color 0xff555555

    # Mouse support
    yabai -m config mouse_modifier alt
    yabai -m config mouse_action1 move
    yabai -m config mouse_action2 resize

    # general space settings
    yabai -m config layout bsp
    yabai -m config bottom_padding 0
    yabai -m config left_padding 0
    yabai -m config right_padding 0
    yabai -m config window_gap 0

    # float system preferences
    yabai -m rule --add app='^System Information$' manage=off
    yabai -m rule --add app='^System Preferences$' manage=off
    yabai -m rule --add title='Preferences$' manage=off

    # float Better Touch Tool Preference window
    # yabai -m rule --add title='^BetterTouchTool' manage=off

    # float settings windows
    yabai -m rule --add title='Settings$' manage=off

    # float Cisco AnyConnect
    yabai -m rule --add app='^Cisco AnyConnect Secure Mobility Client$' manage=off

    # float IntelliJ Preference panes
    yabai -m rule --add app='IntelliJ IDEA' title='^$' manage=off
    yabai -m rule --add app='IntelliJ IDEA' title='Project Structure' manage=off
    yabai -m rule --add app='IntelliJ IDEA' title='Preferences' manage=off
    yabai -m rule --add app='IntelliJ IDEA' title='Edit configuration' manage=off

    # spacebar padding on top screen
    SPACEBAR_HEIGHT=$(spacebar -m config height)
    yabai -m config external_bar all:$SPACEBAR_HEIGHT:0

    echo "yabai configuration loaded.."
    35 changes: 35 additions & 0 deletions spacebarrc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    #!/usr/bin/env sh

    spacebar -m config position top
    spacebar -m config height 26
    spacebar -m config title on
    spacebar -m config spaces on
    spacebar -m config clock on
    spacebar -m config power on
    spacebar -m config padding_left 20
    spacebar -m config padding_right 20
    spacebar -m config spacing_left 25
    spacebar -m config spacing_right 15
    #spacebar -m config text_font "Menlo:Regular:12.0"
    spacebar -m config text_font "Helvetica Neue:Bold:12.0"
    spacebar -m config icon_font "Font Awesome 5 Free:Solid:12.0"
    spacebar -m config background_color 0xff202020
    spacebar -m config foreground_color 0xffa8a8a8
    spacebar -m config power_icon_color 0xffcd950c
    spacebar -m config battery_icon_color 0xffd75f5f
    spacebar -m config dnd_icon_color 0xffa8a8a8
    spacebar -m config clock_icon_color 0xffa8a8a8
    spacebar -m config power_icon_strip  
    spacebar -m config space_icon •
    spacebar -m config space_icon_color 0xffffab91
    spacebar -m config space_icon_color_secondary 0xff78c4d4
    spacebar -m config space_icon_color_tertiary 0xfffff9b0
    spacebar -m config space_icon_strip 1 2 3 4 5 6 7 8 9 10
    spacebar -m config clock_icon 
    spacebar -m config dnd_icon 
    spacebar -m config clock_format "%d/%m/%y %R"
    spacebar -m config right_shell on
    spacebar -m config right_shell_icon 
    spacebar -m config right_shell_command "whoami"

    echo "spacebar configuration loaded.."