Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set monitor resolution via AppleScript System
Prepare for the skinny on how to build a AppleScript to allow for quick resolution changes. This is quite useful if you like to use different resolutions for applications, or if you have TV-out, like I do (which works in only certain resolutions).

After many weeks of learning the power of AppleScripting, I have finally integrated my OS X machine into my living room entertainment system. Largely due to the TV out on the ATI Xclaim, and the Keyspan Digital Media Remote (which I recommend everyone get, because it's sheer genius). The ATI card is selling for peanuts now as it is a few years old, and the DMR isn't very expensive either. I bought my card second hand, and had little help with the setup ... hence this hint for my fellow ultra-geeky peers. This was essential, since the Xclaim card can only output to TV at 800x600|60hz, while I like to use 1280x960|100hz when working on the machine.

First, you will need cscreen, a command line utility to allow screen changes. Once you have it, install it with sudo cp ./cscreen /usr/bin in the Terminal (note you dont have to put it in /usr/bin, but you will have to run it from your script ... and if it's elsewhere, you'll have to make a direct call to it).

Next, create this script:
on run
  do shell script "cscreen" (*get current resolution*)
  set screenResolution to the result
  
  if screenResolution contains "1280" then
    tell application "Stickies" to quit  
    (* because im tired of having 
    to organize all my stickies every time I switch*)
    (*switch to dual [tv/mon] display*)
    do shell script "cscreen -x 800 -y 600 -r 60"
  else if screenResolution contains "800" then
    (*switch to monitor display*)
    do shell script "cscreen -x 1280 -y 960 -r 100"
  end if
end run 
It's not rocket science to figure out how you can customize the script to enjoy your favorite settings. All it currently does is flip-flop between my two resolution choices. Now if you want to go one step further, check out Xkeys, which allows you to assign a script to the function keys -- so when I push Command-F1, the script above gets run, from any application. There's nothing nicer than chilling with a good party shuffle, some red wine, and the G-Force visuals (available for any MP3 software), especially now that I can kick back and control the tunes or videos from the remote while anywhere.
    •    
  • Currently 3.00 / 5
  You rated: 2 / 5 (5 votes cast)
 
[35,611 views]  

Set monitor resolution via AppleScript | 5 comments | Create New Account
Click here to return to the 'Set monitor resolution via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set monitor resolution via AppleScript
Authored by: momerath on Sep 09, '04 12:34:55PM

You should probably put an http:// at the beginning of the keyspan link.



[ Reply to This | # ]
Set monitor resolution via AppleScript
Authored by: tamás on Sep 09, '04 01:55:27PM

What happens if you leave the computer plugged into both your monitor and the TV? Is there a way to control the resolution on one of the two displays, or is cscreen limited to assuming a single display?



[ Reply to This | # ]
Set monitor resolution via AppleScript
Authored by: Frederico on Sep 09, '04 03:57:30PM

csscreen is multi-monitor-aware; you can alter resolutions by device index id:

"6 displays found
Index Depth Width Height Refresh(Hz; LCD displays show 0)
1 32 1280 1024 85
2 32 1280 1024 85
3 16 1152 870 75
4 32 1152 870 75
5 32 1152 870 75
6 32 1280 1024 85
use -h to display all usage options"

"Usage: cscreen [-d <depth>] [-x <width>] [-y <height>] [-r <refresh>] [-s <display>] [-v] [-m] [-f] [-l] [-h]
[-d <depth>] : specifies the bit depth (bits per pixel)
[-x <width>] : specifies the width in pixels
[-y <height>] : specifies the height in pixels
[-r <refresh>] : specifies the refresh rate in Hz
[-s <display>] : 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"

HTH



[ Reply to This | # ]
Set monitor resolution via AppleScript
Authored by: sjmills on Sep 13, '04 10:34:44PM

I didn't know where else to post this, but has anybody else noticed their mouse getting really jerky after installing the Keyspan DMR software and plugging in the USB receiver? I just got the remote today, and all day I've noticed severe lags, where the mouse will freeze for nearly a second. I downloaded the 1.7 updater; didn't help. If the complete crapiness of their GUI is any indication, the rest of the software might suck too. I also noticed I had 6 instances of something named DMRAppleScriptDaemon running at once. That seems a bit excessive. Why don't they just shove everything into the DMRMapperApplication?



[ Reply to This | # ]
Set monitor resolution via AppleScript
Authored by: bean354 on Aug 01, '10 05:59:39AM

This thread might a bit dead, but I figure this is thill the best place to ask:

I've got an monitor with a resolution of 1920x1200 at 60Hz connected up to my MBP running Snow Leopard. The laptop will only output at a maximum of 1920x1024 at 60Hz, can cscreen be used to output at the resolution of my monitor?

Currently, the image is output, but its vertically stretching it, which I find horrible to look at.
Tried all sorts of different cscreen code, but think I've had it wrong each time :/

If cscreen can't do it, anyone have any other suggestions of ways to get it working?

Cheers



[ Reply to This | # ]