mikkelricky / grid-spaces

Grid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Grid spaces

Grid spaces a la TotalSpaces2, but for macOS Monterey, built on yabai and skhd. You also need jq to make the magic work - and jq is a magic tool in itself!

Installation

Install jq:

brew install jq

Check the installation requirements for yabai and install it:

brew install yabai --HEAD
yabai --start-service

Create the desired number of spaces using yabai or Mission Control.

Make sure that yabai works and can focus spaces by running a command like

yabai --message space --focus next

Create the file ~/.gridspacesrc and define the number of columns in your grid:

GRID_COLUMNS=3

Install skhd:

brew install koekeishiya/formulae/skhd
brew services start skhd

Create or edit the configuration file for skhd and define keyboard shortcuts for moving around in the grid, e.g.

cmd + ctrl - up            : «path to this directory»/navigate up
cmd + ctrl - down          : «path to this directory»/navigate down
cmd + ctrl - left          : «path to this directory»/navigate left
cmd + ctrl - right         : «path to this directory»/navigate right

cmd + ctrl + shift - up    : «path to this directory»/navigate --move-window up
cmd + ctrl + shift - down  : «path to this directory»/navigate --move-window down
cmd + ctrl + shift - left  : «path to this directory»/navigate --move-window left
cmd + ctrl + shift - right : «path to this directory»/navigate --move-window right

That's it! Now you should be able to use your grid.

System preferences

yabai and Grid spaces only work as expected when some Spaces system preferences are set correctly:

System Preferences: Set up spaces

  • “Automatically rearrange Spaces based on most recent use” must not be checked
  • “Displays have separate Spaces” must be checked
  • “When switching to an application, switch to a Space with open windows for the application” may be checked and might come in handy if you’ve lost a window for an application that you’re onyl use on special occasions.
# Uncheck “Automatically rearrange Spaces based on most recent use”
defaults write com.apple.dock mru-spaces -boolean false

# You may want to check “When switching to an application, switch to a Space with open windows for the application”.
defaults write 'Apple Global Domain' AppleSpacesSwitchOnActivate -boolean true

# Reload the system preferences
killall 'System preferences'

Furthermore, all Mission Control space switching keyboard shortcuts should be disabled as all Space navigation should be handled by skhd calling the navigate script:

System Preferences: Mission Control space switching keyboard shortcuts

Finally, you may want to Reduce motion to get rid of some animations:

System Preferences: Reduce motion

Updating

brew reinstall yabai
yabai --restart-service

Coding standards

Install ShellCheck:

brew install shellcheck

Check to code:

shellcheck navigate

About

Grid


Languages

Language:Shell 100.0%