You have a docking station for your mac and 2 monitors. For some reason, your display configuration often switches your monitor order.
Not anymore!
First, you need to install Homebrew.
Once done, you need to install DisplayPlacer:
brew install displayplacer
And PHP:
brew install php
To install this script, simply go to Library folder and clone this repository:
cd /Library
sudo git clone https://github.com/SatelliteWP/switch-monitors.git
sudo chmod +x /Library/switch-monitors/run.sh
That's it! The installation is completed.
You can call the monitor switching by calling the script from the terminal:
/Library/switch-monitors/run.sh
It is faster to use the script by mapping it to a key on your keyboard, for instance, using F19.
To do so, open Automator.
Create a new "Quick Action" script. Pick "Run AppleScript" and paste the following code :
on run {input, parameters}
do shell script "/Library/switch-monitors/run.sh"
return input
end run
Make sure to select : Workflow receives Automatic (Nothing) in any application. Leave other options as is!
Save the script as "Switch Monitors".
Then go to Settings > Keyboard > Keyboard Shortcuts..
Then select Services > General and check the Switch Monitors and double click at the end of the line to map the right key.
That's it! You can switch monitors by pressing the right key on your keyboard.