I have zero experience with AppleScript but I’m in the process of trying to learn from examples I find and I’m now turning this into something I could really do with.
Background:
I have an Mac mini M1 set up with three displays for when I’m sat at my desk. I also regularly access this Mac from my iPad Pro using Screens app for Remote Desktop, but this shows all three displays which gets a bit unwieldy on an iPad.
My intention is to create a Shortcut I could remotely trigger which would disconnect/reconnect two of the screens and change the resolution of the main screen to something a little more iPad friendly.
I’d found a method for changing the resolution of the screen using an app called Display Menu and the following AppleScript courtesy of the app’s website…
on run {input, parameters}
tell application "Display Menu"
set theResolution to current resolution on display "Unknown Display"
select resolution "1600x900" on display "Unknown Display"
end tell
end run
This seems to work. I just cannot figure out the first part; how to disconnect the two screens. Is this possible?
Thanks for the suggestion. This looks promising. However I’m struggling to get started…
I have a Mac Mini M1 running Monterey and tried xrandr -q and man xrandr but commands are not found.
Does this come packaged with Mac OS or do I need to install it? And if so, what would be the right way of doing so? I tried Homebrew install but I wasn’t clear what package I would need to install.
I’ve tried googling and looking at YouTube vids but struggling to find anything to get me started in terms of installation of xrandr. If you can provide me any other details which would push me a little further in the right direction, this would be great. Thanks.
I think it was installed by default for me - but I don’t own an M1 Mac to check this on … I don’t even know if that is the difference. It could be it was installed as a dependency at some point, but since I got this Mac a few years back I know I have not explicitly installed it as I have had no need of it for many years.
I expect Home Brew probably would too and is my preferred Mac package manager these days, but I don’t know what cask it would be as I already have it, and it isn’t guaranteed to be available.
I can see Mac Ports does still seem to offer this. Will have a look. Thanks.
Furthering my experiments with Display Menu app, I expanded my code to switch the set up to mirroring which DOES give me a single screen to Remote Desktop to. Only downside, which is still not great is that toggling mirroring off again, arranges the displays side by side instead of original layout; the 4k sitting over the top of the two 1080ps which were side by side. I suspect this is where xrandr could help with it’s placement capability.
on run {input, parameters}
tell application "Display Menu"
toggle mirroring
set theResolution to current resolution on display "Unknown Display"
select resolution "1600x900" on display "Unknown Display"
end tell
end run