Skip to content

Instantly share code, notes, and snippets.

@adrianlungu
Last active January 28, 2023 02:24
Show Gist options
  • Save adrianlungu/428f77c428fe72b9fd49737976af1494 to your computer and use it in GitHub Desktop.
Save adrianlungu/428f77c428fe72b9fd49737976af1494 to your computer and use it in GitHub Desktop.
Swap identical MacOS displays to fix issue where they are in the incorrect order after sleep

Fix Display Swapping

As described here, MacOS has a nasty habbit of resuming sleep or booting up with external monitors swapped in between when using multiple identical monitors.

Using DisplayPlacer and help from the community, we can configure a BetterTouchTool keyboard shortcut (or other shortcuts) to swap them in their proper place when they bootup in the incorrect order.

How

  1. Install DisplayPlacer by running this in your terminal (requires Homebrew)
brew tap jakehilborn/jakehilborn && brew install displayplacer
  1. In BetterTouchTool, create a new Keyboard shortcut, i.e. Opt + Shift + S
  2. Select Execute Shell Script as an Action
  3. Paste the following script as a bash script and Save
/opt/homebrew/bin/displayplacer list | tail -n1 | sed 's/displayplacer //;s/id:\(.\{36\}\) res:\([0-9x]\{7,9\}\) \(.*\)id:\(.\{36\}\) res:\2/id:\4 res:\2 \3id:\1 res:\2/g' | xargs /opt/homebrew/bin/displayplacer
  1. Profit!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment