Set iMac Display Settings for Mirroring and Resolution

ernstcs
Contributor III

In the past we've had something way back that I could use to set the screen resolution of a Mac Mini that was connected to a VGA splitter so I could run it to the local monitor and the projector. The Mac couldn't really tell what was attached to it and set the resolution higher than the projector could handle. A login policy with the script worked great.

I haven't used it in a while, but the issue I have now is a bit different. I have an iMac at the teaching station now, and it connects to the projector with the dongle out the back. By default the displays don't mirror, and again may not set the correct resolution for the projectors display.

Is there something new I'm missing that I can use to set both mirroring and then both display resolutions properly with a login policy? The settings stick for a user once they set it, but it's per user so it has to happen at each login. There has never been a command line option just built into the OS for this (to my knowledge) and it pisses me off.

I believe I've even tried copying what I thought were the proper settings files into the skeleton profile, and that didn't appear to work. HELP!

17 REPLIES 17

timsutton
Contributor

There was some discussion about command-line screen resolution tools in the ##osx-server IRC channel a few months ago:

http://osx.michaellynn.org/freenode-osx-server/freenode-osx-server_2012-06-04.html

This seems like the most recently-updated solution:

https://github.com/jhford/screenresolution

I have no idea whether this allows setting the resolution once and having it be set permanently for all users (in other words, the equivalent of choosing a resolution and mirror mode as an admin user). I'd previously used a utility called 'newscreen' that would set the resolution correctly, but not persist this setting to the configuration plist where this information is stored.

Of course, this could be made into a LaunchAgent that runs for all users on login, but it'd be nice to have the same functionality as just setting it in the Displays prefpane GUI.

timsutton
Contributor

To follow up, I just took a look at the code for John Ford's screenresolution tool.

The method that actually performs the screen resolution change is currently using kCGConfigureForSession as the configuration scope:

https://github.com/jhford/screenresolution/blob/master/main.c#L212

OS X API notes here:

https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html

I just substituted kCGConfigureForSeesion for kCGConfigurePermanently, ran 'make' to recompile the binary, and tada! You can now run 'screenresolution set 1920x1080x32@0' (or whatever your resolution) and it will stick for all users, provided it's done by an admin user.

My clone with this one simple change is here:

https://github.com/timsutton/screenresolution

But you'll need to run 'make' from within the screenresolution directory to compile it yourself.

Wish I'd discovered this tool before I spent hours running around to classrooms, manually setting display mirroring and resolutions on Macs hooked up to Crestron boxes.

ernstcs
Contributor III

I will give this a look this week. Thanks a lot! =D

Kumarasinghe
Valued Contributor

Anyone got this working properly?
I want to get the mirroring working from a script. Can anyone kindly put the full instructions to get this working on OS X 10.8 ?

Thanks

Kumarasinghe
Valued Contributor

All good. Found an app called MirrorDisplays. Thanks

zskidmor
Contributor

How did you use the Mirror Display App? I have the command line tool loaded on the iMacs themselves and then I created a policy that runs the command line to enable mirroring upon login. What I find is that it runs, but then OS X resets back to extended (its like the command runs too early). Any advice would help

Kumarasinghe
Valued Contributor

OK.

Please check this;
Go to "Computer Management Framework Settings" > Login/Logout Hooks > Untick "Perform login actions in background" if it is ticked.

Then do another test.

What I do is, I put the software in /Applications folder and then call this at login.

/Applications/MirrorDisplays.app/Contents/MacOS/mirror -on

aptms
New Contributor

This thread helped me get to the MirrorDisplays app, but for whatever reason I can't get mirroring to turn off. Using /Applications/MirrorDisplays.app/Contents/MacOS/mirror -on (or -t for toggle) it will be able to quickly turn on mirroring no problem. -off (or -t) does not return to extended displays mode.

Running 10.9.5

Posted comment on github page. Apparently this is an issue for Yosemite users as well.

etippett
Contributor II

@timsutton Thanks, this is amazing! You saved me the same task of running around campus!

etippett
Contributor II

@timsutton Hey, Tim. After working with your fork of screenresolution a bit more, I've hit one small stumbling block I wonder if you can assist with. My problem is that we tend to set our mirrored resolution to favor the native aspect ratio of the projector, which sadly does not match the connected iMac. Because of this we need to be able to use screenresolution to set resolutions that only become available in the GUI when using Display System Prefs to set the "Optimize for" setting to "VGA Display/[insert projector model here]". The output of screenresolution list seems to mimic what is available based on this setting. Since the "Optimize for" setting defaults to the internal display the resolutions we want can't be set with screenresolution. Do you know of a way via Terminal to change the "Optimize for" setting so that the external projector resolutions are available to the screenresolution executable?

Thanks!
Eric

ebioit
New Contributor II

@etippett I know this is an older post but I guess I'm curious to know if you found a solution for new mac OS and setting screen resolution per user? It would be useful for us to set a default setting for our laptop users.

mgshepherd
Contributor

Are there any current tools that are usable for Sierra in locking in the desired screen settings? I'm using JAMF for the first time during our new school year and I'm having a time in labs with teacher stations that are using VGA connections. Sometimes the resolution and mirror settings will stick. On the other hand sometimes it will lose the settings and the com.windowserver.plist file goes back to default. In using JAMF I've stopped using Deep Freeze in favor of not having admin rights but I will say when I used Deep Freeze I never had this issue. I could set the resolution the way I wanted it, copy the user folder to the default template location and I would never have issues.

Does anyone have ideas to solve this? I'm testing locking the com.windowserver.plist file to see what that does. Any help would be appreciated.

Nix4Life
Valued Contributor

@mgshepherd I can confirm that cscreen did work with Sierra 10.12.4. I used it with outset to set the screen resolution on login. It may be worth a shot

Larry

mgshepherd
Contributor

Great! I'll give that a try also I found a utility called Mirror Displays that takes care of mirroring for the iMac and the projector. This solves both dilemmas of getting the correct mode/resolution whenever someone logs in. Thanks for the suggestion.

Mirror Displays can be found here: http://fabiancanas.com/open-source/mirror-displays

I'll post my findings later this week once I've tried it in the wild.

mgshepherd
Contributor

So far the settings have been holding well in our labs and classrooms. I deployed both cscreen and mirror along with a login script that first checks to make sure the display and projector are mirrored. Next it forces the resolution on both screens to be set. My next revision of the script would be to check the resolution and change if needed.

uurazzle
Contributor II

Hello:

We have a open-source Python library which can modify your Mac's display settings manually or automatically and can easily work using a Jamf Pro via a policy and scope. I believe this will completely meet your needs. Take a look at the following GitHub repository...

Display Manager
https://github.com/univ-of-utah-marriott-library-apple/display_manager

Let us know if you have any questions, problems or feature requests.

Have an update for Ventura and onward? No more Python, just a version of Python3 installed.