cscreen

I am the original developer of the command line display management utility, cscreen. The original version targeted OS X on PPC and is quite old. I have, however, received requests for a copy of this in situations where someone is still running an older Mac and either is installing it for the first time or is rebuilding their PPC Mac and wants to replace their original. This link should give you the old PPC version of cscreen.

I have also received requests for an upgraded Intel version of cscreen. I do not have a Retina display so I don’t know how this will behave on such machines, but I have upgraded cscreen and recompiled it for Intel and switched to the new non-deprecated APIs. This link should give you the new Intel version of cscreen.

Naturally if you run into any problems, please let me know.

Updated 2012-11-07: I’ve pushed out a new version of cscreen Intel, adding the -i parameter which allows you to use display ID values in lieu of the index, when selecting a display to operate on. These display ID values come from OS X and are assigned permanently when a display is connected to the system. As a result they persist across reboots as well as when the displays are reordered (for example when making a new display primary). As a result you can script work targeting a specific display ID without worrying about index changes. Also I fixed a bug where running cscreen with only an index selection but no other options could potentially cause a resolution change.

Updated 2012-12-23: Yet another new version of the Intel version, this time making it a Universal binary, set up for both 32 and 64 bit systems. Merry Christmas!

44 replies on “cscreen”

Cross posted at ASC with you. Sorry about that. BTW, the 4/28/08 version does well with my Intel-based 27″, but I will be updating to the new one. Many have inquired about getting the old one, but it went missing. This is from the Terminal.

$ cscreen
1 display found
Index Depth Width Height Refresh(Hz; LCD displays show 0)
1 32 2560 1440 0

$ cscreen -h
Usage: cscreen [-d ] [-x ] [-y ] [-r ] [-s ] [-v] [-m] [-f] [-l] [-h]
[-d ] : specifies the bit depth (bits per pixel)
[-x ] : specifies the width in pixels
[-y ] : specifies the height in pixels
[-r ] : specifies the refresh rate in Hz
[-s ] : specifies which display to use (defaults to main display)
use a as the option to -s to specify the action on all displays
[-v]: display valid modes (use -s to specify display or nothing for the default)
[-m] : require an exact match
[-f]: forces settings (ignores safety mechanisms; USE AT YOUR OWN RISK)
[-l]: lists the current displays and modes
[-p]: sets the requested display to be the primary display
[-h]: displays the usage

Hi! I have downloaded the program. Where do I put it so I can launch a terminal session and run it without having to direct the entry all the way to the directory (i.e. /usr/foo/cscreen)? Do I need to change the permissions to run it?
I’m comfortable with existing programs that Apple installs, but I’ve only used used a package manager in the past to add new programs. I don’t remember the name of it but it was a repository of useful add-ons back when OSX was still new.
Thanks!
Ian

Hi Ian,

You are probably thinking of fink. Fink is intended to allow you to use typically non-OSX *NIX tools on OSX and Darwin. cscreen is a native app, albeit command line, so it wouldn’t be found there.

When you have pulled cscreen out of the .dmg, you can copy it anywhere you like that is in your path. Try ‘echo $PATH’ in Terminal to see what folders are currently in your path. If you are comfortable doing so, you can add a folder of your own choosing to your path. You will also need to set execute permissions as well (e.g. ‘chmod o+x cscreen’ in Terminal) when you get it into place.

If you are curious, here is a link I found after a quick Google search about how to alter your OSX PATH setting.

Yup it was Fink (which I miss—had lots of cool easier things like wget instead of curl).
Actually I was a bit of an idiot. I can indeed run it by typing “cscreen” at the prompt (the program is at /usr/bin). What doesn’t work is “man cscreen” and that is why I thought it wasn’t working at all. However for now I should be able to work with it referencing your site for the man page.
Thanks!
Ian

Ah… I think at one point I was considering putting together a man page but I wasn’t sure how much better that would be than just using the output from ‘cscreen -h’.

Hi Lynn,

Thanks a ton for the Intel version!

I was trying to use cscreen to set the screen resolution of a remote OSX Lion terminal, but cscreen -v only lists 800×600 and 640×480 (with depth 32 and various refresh rates). The system boots with a resolution of 1280×1024, and System Preferences > Displays shows a long list of options starting from 1024×768 to 1920×1080.
The force (-f) switch also couldn’t set a resolution higher than 800×600.
I’m using the machine over VNC and running cscreen in an SSH session.

Any issue you can think of?

Thanks.

A few things come to mind:

Are you running the server headless? I know you mentioned that you could navigate System Preferences but I’m wondering if you are removing the display during normal VNC connection.

Does your VNC server software have any settings to control resolution? If I recall correctly, some VNC server packages provide preset resolution configurations which would possibly affect what the display subsystem would report.

You mentioned that you are connecting via VNC but using cscreen via SSH. What happens when you launch Terminal in your VNC session and run it there? Do you see different results?

I’m trying to run cscreen on my Hackintosh (which has a Pentium 4 CPU) but when I run cscreen I get the error:
sh: /usr/bin/cscreen: Bad CPU type in executable

At first I thought perhaps I had inadvertently downloaded the older PPC version of cscreen but making sure that I had your Intel version I reinstalled and got the same error. Since it’s a Hackintosh I know I’m in no man’s land but if you have any suggestions I would greatly appreciate them.

Thanks,

Darrell

From what I can gather, the “Bad CPU type in executable” message typically occurs when there is a bitness mismatch in the executable, like trying to run a 64 bit executable on a 32 bit system.

You mentioned you are using a Pentium 4 CPU, which was at one point offered in 32 bit only varieties and eventually was offered with a 64 bit option as well. Do you happen to know what bitness you are set up to use? 32 or 64? The cscreen executable for Intel would almost certainly have been a 64 bit binary, so on a 32 bit system I would expect this error.

If that’s not the case, then it’s back to the drawing board. 🙂

That sounds like the likely cause. It’s an old CPU so probably 32bit. Oh well, I’ll continue my pure Applescript approach.

Thanks for the help.

Hi, thank you for this program but … it does not work with my mid 2010 Mac Pro.
I have a DVI monitor which is seen but screen does not see my TV on another port. The configuration of the video card is the following :

DVI port : samsung monitor.
display port n°1 : nothing
Display port n°2 : display port to hdmi adapter -> TV

Any idea ?

Michel, I’m not sure why cscreen wouldn’t see your display. I too have an external display connected via display port to HDMI adapter, though it’s an LG display and not a TV. Still, I wouldn’t think it would be a problem. Also I’m using a Macbook Pro, not a Mac Pro though again, can’t imagine that’s the issue. I can try hooking up my laptop to my TV to see what happens.

Out of curiosity, what happens if you use the other display port?

Thanks for porting the cscreen utility.

I’m wondering if you could look implement the ability to explicitly specify which screen to address. While researching your utility, I came across another called fb-rotate (http://modbookish.lefora.com/2010/06/29/a-unix-utility-to-change-the-primary-display-on-os/) whereby you can manipulate screens based on an explicit DisplayID rather than display “index” which changes after running cscreen -p.

I feel that your cscreen -p is superior to the fb-rotate -m (as your’s brings the dock along and actually swaps displays completely (windows and all) whereas fb-rotate simply moves menubar) .. but I do like the -i switch of fb-rotate better since it allows me to truly understand screen *arrangement*, as well as fb’s added feature of being able to explicitly address the display by DisplayID.

Thanks for your efforts!

jpf

Hi Lynn,

is it possible to switch between 1080i and 1080p with cscreen? I can’t seem to figure out how to do this.

Thanks,
Robin

Hi Robin,

Theoretically… maybe. 🙂 I suspect it depends on whether the 1080i and 1080p modes get listed as separate modes.

I’ll look into this a bit tonight while I’m working on JP’s request.

-Lynn

Hello! Thanks for the great tool. I was wondering if it is possible to add screen rotation to this? One of the problems I have is my second monitor sometimes is not set to the correct resolution, so this tool should be able to help me with that – but I think since the display is currently set to 90 degrees rotation the resolution is not setting correctly. (either that or I’m using the tool incorrectly)

In any case, thanks!

I am also running a hackintosh hp mini 110 with osx 10.5.8 and i get the bad cpu type error as well with the intel version, and so for the heck of it i’ll give the old ppc version a shot and it works like a charm. hope this works for you as well darrell

Hi, is it possible to switch to a HiDPI resolution? In mountain lion resolution list I can select 960 x 540 (HiDPI) mode which looks great in media center usage. It would be great if I could create a script with cscreen to change between 960×540(HiDPI) mode vs. 1080P for XBMC.

I tried to change resolution manually (cscreen -d 32 -x 960 -y 540 -r 60) but unfortunately the OS X didn’t pickup the HiDPI-mode.

I like the ability to switch which screen has the menu/dock.
I use $cscreen -s 2 -p from a dock icon.

Is there a way to keep the screen position as is?
I usually have to manually correct.

Thanks,
Eric

Hey, the tool is good and it does work as you intended in Retina Display Mac. However the screen looses clarity since natively retina display uses what they call a scaled resolution. I do not know how exactly it works so I can’t get around it.

Thanks for this awesome cscreen utility. It works perfect on my 64bit Intel Macs. However, my 32bit Intel Macs do not work with cscreen. It looks like cscreen is 64bit only? I see the comment above, running on a Pentium. My CPU is not Pentium, it’s the CPU that Intel released before the Core 2 Duo. These CPU can only run 32bit executables.

Is it possible to recompile the utility for 32bit for those of us who have 32bit only CPU?

Hi Eric,

Do you mean after a reboot, your selection of which screen has the menu/dock doesn’t hold? Or that running the script from the dock icon makes the change and then it immediately reverts?

Hi Aaron,

Okay, I did a 30 second check in the Xcode settings and found the option to create a universal 32/64 bit binary. The newly built executable checks out as both types with the ‘file’ command and runs fine on my machine.

Grab an updated copy of the Intel .dmg file from the link above and give it a try. If that works, that would suggest that 32 bit users would also have the option of using cscreen, which.. “yay”. 🙂

Hi Cem,

You aren’t the only user having issues with the various Retina resolutions. I’m going to need to sit down and play around with things a bit more.

I did end up getting a new Macbook and opted for one with the Retina display (short story, old laptop’s battery was bulging and causing me problems) so I can do testing on my own machine without having to rely on others testing it blindly.

Hi Ville,

By HiDPI resolution I assume you mean Retina? If so, you aren’t the only user having issues with Retina resolutions. I’ll need to play around with this a bit and see what’s what.

This is an awesome Christmas present indeed. I tried the new version on my 32bit Intel Mac and it worked perfectly!

Thanks!

Happy new Year!!

look’s like you small app is the solution to my MediaCenter Problems. But, on a OSX 10.5 I get the error:dyld:

unknown required load command 0x80000022
Trace/BPT trap

Any ideas how I can run this on a 10.5 MacMini?

Cheers, Chris

Hi Chris,

Happy New Year to you as well. 🙂

Can you tell me what specific version of OS X you are using (e.g. 10.5.8) and what processor your Mac Mini has (e.g. G4, Intel) and which cscreen .dmg file you grabbed?

From what I can tell, a number of things might be happening here, chief among them an architecture mismatch between the binary and the system you’re running on.

Regards,

-Lynn

Hi!
Awesome program! Just one thing, when I use “cscreen -s 2 -p” my displays gets rearranged. I would like to keep the order when switching displays and to be able to switch them back (in the same order) with the same command. Is this possible?

If I wasn´t clear, the display order should always stay the same!

Hi, Lynn —

Thank you for your impressive tool. It would suit my needs perfectly if it weren’t for the fact that I’m experiencing the same problem as Sirius, but with a different setup. I am on a mid-2010 iMac running 10.7.5. The iMac is connected to an Epson projector via an Apple-brand Mini DisplayPort to VGA adapter.

cscreen -v is only showing 640×480 and 800×600 options in a wide variety of refresh rates:

DisplayID Index Depth Width Height Refresh
5b81c5c1 1 16 640 480 90
5b81c5c1 2 32 640 480 90
5b81c5c1 3 16 640 480 95
5b81c5c1 4 32 640 480 95
5b81c5c1 5 16 640 480 100
5b81c5c1 6 32 640 480 100
5b81c5c1 7 16 640 480 120
5b81c5c1 8 32 640 480 120
5b81c5c1 9 16 800 600 90
5b81c5c1 10 32 800 600 90
5b81c5c1 11 16 800 600 96
5b81c5c1 12 32 800 600 96
5b81c5c1 13 16 800 600 100
5b81c5c1 14 32 800 600 100
5b81c5c1 15 16 800 600 120
5b81c5c1 16 32 800 600 120
5b81c5c1 17 16 640 480 60
5b81c5c1 18 32 640 480 60
5b81c5c1 19 16 640 480 73
5b81c5c1 20 32 640 480 73
5b81c5c1 21 16 640 480 75
5b81c5c1 22 32 640 480 75
5b81c5c1 23 16 640 480 85
5b81c5c1 24 32 640 480 85
5b81c5c1 25 16 800 600 56
5b81c5c1 26 32 800 600 56
5b81c5c1 27 16 800 600 60
5b81c5c1 28 32 800 600 60
5b81c5c1 29 16 800 600 72
5b81c5c1 30 32 800 600 72
5b81c5c1 31 16 800 600 75
5b81c5c1 32 32 800 600 75
5b81c5c1 33 16 800 600 85
5b81c5c1 34 32 800 600 85

However, the Displays preference pane shows resolutions from 800×600 up to 1920×1080. (Curiously, it doesn’t even show 640×480 options while cscreen does.) Like Sirius, I tried using the -f option without success.

— Steve

Just wanted to say thanks. CSCREEN does exactly what I needed it to do (toggle the primary display). Fast, Easy, Terrific.

Great! I’ve searched something like this for months!
I’ve the same little problem that Hannes has.
I’ve two displays, let’s name them A and B. The only way to switch actually is ./cscreen -s 2 -p.
Anyway, when the switch is done, my display are rearranged, that is the monitor that is on the left on my desk is on the right in osx, and I manually have to move it on the left again, through the system preferences.
Is there any way to correct this behaviour?

Thanks,
Francesco

Hi,

Thank you SO much for this little utility. I imagine it would be life saver for many.

Unfortunately, on my late 2012 iMac running 10.8.3 it always changes the resolution of the main screen no matter which options I use.

./cscreen -l gives me the following information:

DisplayID Index Depth Width Height Refresh
42801c0 1 32 2560 1440 0
5b81c5c1 2 32 640 480 60

I have tried:

./cscreen -x 1440 -y 900 -s 2
./cscreen -x 1440 -y 900 -s 1
./cscreen -x 1440 -y 900 -i 5b81c5c1
./cscreen -x 1024 -y 768 -i 42801c0
./cscreen -x 800 -y 600 -s a

And in each case it changes the resolution of the main screen (which has an id of 42801c0). Even the last command (-s a) modifies only the main screen, leaving the external screen set to the non 800×600 setting I had switched it to via system preferences (In other words, it does not touch that screen at all).

Thanks again for the tool. If this is something you are still working on, I just thought I’d give you a little feedback.

Is there any way to be able to turn off a screen using this utility? Sometimes I need to disable a monitor, but need to do it programmatically, vs physically, since the mac still treats the screen as existing.

Found your website. Tried via command terminal you cscreen: very interesting but needs an improvement.
In my LAN I use a blind (without monitor) Macmini with Osx Lion Server. The main problem for Mac is their inabilty to set-up (force) a default resolution WITHOUT monitor, so by mistaking with switchresx prefpanel, I lost the video connection during VNC session. No way with restart, I Must plug an external monitor and solve the screen resolution.

If your program were able to FORCE a lost or default screen resolution …

In my case this is the output coming from an ssh session with cscreen:
Sep 29 17:52:22 abk-macmini.local cscreen[565] : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
Cannot get displays (1011)

I tried with -s, -v, -l and “-s a” switches without luck, always the same message.

Can anyone please explain to me how to install CScreen to activate it with a combination of keys (shortcut) or clicking on an icon? I’m new with mac and have no coding skills. I downloaded it, double clicked it, a terminal window appeared and….from here I don’t know what should I do. thanks

Hi George,

Unfortunately cscreen is really just a command line tool meant to be run from a Terminal window or something similar. It has no GUI and while it may be possible to make it run via shortcut keys, that would require wrapping it in a shell and/or using hot key settings or something special to fire it off. Perhaps using Automator scripts?

Pardon me for asking but if you want to do this from the GUI, is there a reason the standard System Preferences options aren’t working for you? Are you finding that your screens are not the right resolution a lot and need to be changed with the click of a button on a frequent basis?

-Lynn

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.