Changing screen resolution from the command line on a Mac

So recently I was working on a mirror and I ran into a problem setting the correct display resolution for the tv that makes up the “reflective” surface of the mirror. Basically the computer would think it was smarter than me and set a stretched resolution instead of a native one on reboot creating more of a fun house mirror effect than anything else.
To solve the problem I knew I was going to have to script something so I started poking around in applescript and quickly realized that there was no library to change the resolution, and I’d have to default to using click actions and menu items. Needless to say, this is terrible idea so I gave up on applescript and started looking around for some command line tools.
I found cscreen, but the project has been closed up and the developer took down the app. Shucks. Then I asked the venerable Adam Miller for a hand. After some google-ing we found this post in which a guy shares his code for a small C app to change the resolution. A few moments and a compile later and we had an app! An app that is super simple and works really well, in leopard even!
Here is a zipped up copy of Newscreen, remember its command line only, so you’ll need to put it somewhere on your hard drive and use it from terminal, Mac only.
Here’s a usage example: newscreen -h 1440 -v 900
The other beautiful thing about this is that you can set custom resolutions. For instance, I have a Mac Mini at home that I use as a media hub and it’s hooked to an HDTV. The Mac Mini doesn’t have a decent recommended resolution for the TV so I was able to use this tool to set a custom res, and again it worked like a charm! Now it looks great and actually fits on the screen.
Oh and standard disclaimer here, this works for me but might not for you. Use at your own discretion, this is provided as-is no warranty implied or otherwise at all, ever. And I’m not responsible if it destroys your computer or files. Or if it murders anyone in your family.
UPDATE: as pointed out in the comments, this is intel only! for now. I’ll see if I can compile a universal version later.

10 comments

SwitchResX is also great GUI tool for getting weird resolution outputs to work on the Mac!

http://www.madrau.com/html/SRX/About.html
Oh yeah, i totally looked at switchresx, the only thing was that i didn't need something overly complicated that could potentially fail, and i needed something i could script. since newscreen is a command line only, it was easy to write a simple bash script that changed the res.
When I tried to run newscreen the terminal displays this message:

"Bad CPU Type in executable"

Are sure this file is a universal one? Or did you compile it for just intel?
When I tried to run newscreen the terminal displays this message:

"Bad CPU Type in executable"

Are sure this file is a universal one? Or did you compile it for just intel?
@Melli - sorry! intel only. should have mentioned that before, though I'll see about compiling a universal one. post updated!
I'm running an Intel Mac Mini. When I try to run Newscreen (newscreen -h 1440 -v 900), I get "Bus error". Any ideas?
hey bill,

what version of mac osx are you using?
I have been searched down a similar path looking for a direct script way to change resolution for a remote access program to an optimal resolution and then change back to my normal 2560x1600 when completed with remote access. This command line program scripted easily and worked out well for what I was wanting to do.

Many thanks!

Dean
Tried it, but all it does is set my res to the highest possible resolution! doesn't matter what params i set, it always bumps my core duo mac mini to 1920x1080.

-Andy
@andy

think you could tell me what version of mac os you have installed? the the graphics card that is in that thing?
add a comment


Hi we kind of need your email for security purposes. We promise to never ever give it to deposed Prince Casper Otobo.


HTML is not allowed. URLs will be turned into links.