Switching main displays with Alfred and DisplayPlacer on MacOS

One thing that bugs me about switching main monitors in MacOS is that there’s no shortcut to do it. You have to go into settings and drag that little bar to the display that you want to be main.

I’ve got a setup where my iMac is on a standing desk and my second monitor is on my normal desk, and using the wireless keyboard and mouse I can either stand or sit. When I’m sitting I want my external monitor to be the main, when I’m standing I want my iMac to be the main. Using Alfred and displayplacer, I was able to set up a nice quick switch.

  1. Install displayplacer
  2. Set your monitor configuration up the way you want for your first configuration (in my example, it was with my iMac as the main monitor)
  3. Run displayplacer list This will give you the displayplacer command to switch to that configuration. Copy it into a text file and label it for later use.
  4. Switch your monitor configuration to your second configuration (in my example it’s my external monitor is the main monitor)
  5. Run displayplacer list again. This will give you the displayplacer command to switch to that configuration. Copy and label it like in step 3.
  6. Now open up Alfred* and make a new Workflow. Use the starter template Keyword to Script
  7. Double click the keyword box and enter in a name and keyword you want to use to switch to the configuration. In my case, I wanted to type “imac main” in Alfred to make the switch.
  8. Double click the script box and enter the displayplacer command from the previous step for your first configuration. You may notice the command I pasted is slightly different than the command I got from the terminal. That is because Alfred initially couldn’t find the displayplacer command, but adding its full path /usr/local/bin fixed that problem.
  9. Repeat steps 7 and 8 with the second configuration.
  10. Boom! You can now use Alfred to switch between monitor configurations.

* While I used Alfred, it does cost money so if you’re looking for a free solution, it is possible to do within the MacOS Automator app. I originally set it up using that and tied it to a keyboard shortcut, but found that it sometimes conflicted with whatever app I had in the foreground.

Related Post

What do you think?