I spent some time today trying to find a solution for this and didn’t quite find one that fit my needs so ended up cobbling together something from older posts. Figured I’d share if anyone is looking to do similar things and to see if anyone has input for improvements.
I often need to screenshare on calls and many members of the call will be on laptop screens with a lower resolution than my external display. My non-automated workflow was to tell everyone to give me a min prior to sharing and go into system preferences to change the resolution. This has gotten tiring and felt like a prime candidate for automation.
I wasn’t able to find a Shortcut that did this but found a SO post about using apple script. This was my starting point.
Below is my final script. I also wanted to be able to trigger this from raycast or from a keyboard shortcut so that is what the additional Raycast meta in comments are about.
Currently this is working on macOS Monterey 12.6 and hasn’t been tested on any other versions.
#!/usr/bin/osascript # Required parameters: # @raycast.schemaVersion 1 # @raycast.title Toggle Resolution # @raycast.mode silent # Optional parameters: # @raycast.icon 🤖 set monitor to 2 tell application "System Preferences" activate set the current pane to pane id "com.apple.preference.displays" delay 2 tell application "System Events" tell window "Displays" of application process "System Preferences" click button "Display Settings…" delay 2 click row monitor of outline 1 of scroll area 1 of sheet 1 click radio button "Scaled" of radio group 1 of sheet 1 set elems to entire contents of UI element 6 of sheet 1 try set selected_button to button "Resolution5, Selected" of UI element 6 of sheet 1 click button "Resolution1" of UI element 6 of sheet 1 on error click button "Resolution5" of UI element 6 of sheet 1 end try delay 0.5 click button "Done" of sheet 1 end tell end tell end tell # The next line is optional and could be commented out by prepending with a hash (#). delay 2 quit application "System Preferences"
As mentioned above, I’m happy to take feedback on this. I haven’t done hardly any applescripting so I’m sure there are better ways of doing things.