This is a simple AppleScript that can be used with Automator to toggle Mirror Display option using a keyboard shortcut.
This can be useful if you have multiple displays and want to switch between Mirror Display option and default extended display option with a single keyboard shortcut.
Normally the same task can be done by using the existing CMD
+ fn
+ F1
keyboard shortcut.
However, it doesn't set "Optimize for:" option to the Built-in Display. This script does that.
- Create a new Application with the Script using the Automator App.
- Give the Application accessibility cabability from
System Preferences
->Security & Privacy
->Accessibility
. - Create a new Quick Action from Automator to launch the Application.
- Finally from
System Preferences
->Keyboard
->Shortcuts
->Services
->general
, activate the Quick Action with the keyboard shortcut of your choice.
- Better Error Handling.
- Revert back to the old active state of System Preferences if it was already running.
- Give time limit to
repeat until
blocks.
The toggle-mirror-display script is licensed under the MIT license.