Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save henrik242/faae63c5cc7c49b7cb8360b2498f87c4 to your computer and use it in GitHub Desktop.

Select an option

Save henrik242/faae63c5cc7c49b7cb8360b2498f87c4 to your computer and use it in GitHub Desktop.

Revisions

  1. henrik242 renamed this gist Feb 18, 2020. 1 changed file with 0 additions and 0 deletions.
  2. henrik242 created this gist Feb 18, 2020.
    10 changes: 10 additions & 0 deletions Organize screens and windows in macOS.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    1. Install software
    ```
    brew install yabai
    brew install displayplacer
    ```
    2. 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
    44 changes: 44 additions & 0 deletions fix-all-displays.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    #!/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