Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik242/faae63c5cc7c49b7cb8360b2498f87c4 to your computer and use it in GitHub Desktop.
Save henrik242/faae63c5cc7c49b7cb8360b2498f87c4 to your computer and use it in GitHub Desktop.
  1. Install software
brew install yabai
brew install displayplacer
  1. Create hotkey
    • Use Automator --> Quick Action --> Library --> Utilities --> Run Shell Script
    • Set Workflow recieves: no input and Shell: /bin/bash
    • Add script and save
    • Assign shortcut in System preferences --> Keyboard --> Shortcuts -> Services -> General
#!/usr/bin/env bash
# Find current display setup with `displayplacer list`
if [[ "$1" != "nodisp" ]]; then
displayplacer "id:AC430A46-436F-287B-3CD7-0BC5BFDE526F res:2048x1280 hz:59 color_depth:8 scaling:on origin:(0,0) degree:0" \
"id:BDAD60E9-108C-3FE8-D0B7-1EBDCA40FD17 res:3008x1692 hz:60 color_depth:8 scaling:on origin:(1053,-1692) degree:0" \
"id:5BE75D28-9C63-0250-6A66-7EBBB6B3787C res:3008x1692 hz:60 color_depth:8 scaling:on origin:(-1955,-1692) degree:0" &
sleep 2
fi
window_pid() {
SELECTOR=$1
FIELD=$2
yabai -m query --windows |jq ".[] | select (.$FIELD | test(\"$SELECTOR\")) | .id"
}
move_window() {
for WINID in $(window_pid "$2" "$1"); do
yabai -m window $WINID --move abs:$3
yabai -m window $WINID --resize abs:$4
done
}
move_space() {
yabai -m rule --add app="$1" space=$2
}
move_space "^Firefox" 5
move_space "^Google Chrome" 2
move_space "^Kafka Tool" 5
move_space "^Mail$" 3
move_space "^[CK]alend[ae]r$" 3
move_space "^IntelliJ" 4
#move_space "^Safari$" 2
move_space "^Terminal" 1
move_space "^Spotify" 2
move_space "^Slack" 1
# Find current window placements with `yabai -m query --windows`
move_window title 'src/travel-app2]' -1597:-1650 2605:1650
move_window title 'src/travel-app]' -1955:-1669 2132:1609
move_window app '^Mail' -523:-1650 1557:1543
move_window app '^[CK]alend[ae]r' -1932:-1659 1366:1617
move_window app '^Firefox' 1060:-1662 1832:1595
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment