I’m on a PowerBook that gets deployed in a wide variety of settings, often using an external monitor (big honkin’ CRT, presentation projector, DVI, etc) as the primary display, in other places & times using one as auxiliary (smaller CRT, etc).
Sometimes I hook up and boot and the OS erroneously tries to drive the external at some combo of resolutution + refresh rate that it doesn’t support, and if it really wants to add insult to injury it makes that one the primary display. Boy is that ever fun.
Last time, I fixed the problem by disconnecting the monitor and nuking the files “windowserver.xxxxxxxxxxx.plist” and “preference.displays.xxxxxxx.plist”
in ~/ and also the file “com.apple.windowserver.plist” in /Library", rehooked the monitor and rebooted. Got the screen back at the expense of all my settings for all my various monitor configurations.
I’ve been playing around with GUI scripting and have the following working:
tell application "System Preferences" activate end tell tell application "System Events" tell application process "System Preferences" set frontmost to true click menu item "Displays" of menu "View" of menu bar 1 click menu item "Display" of menu "Window" of menu bar 1 end tell end tell
That (in case it isn’t obvious) peels open the Display prefs and puts me on the window for the (black, wrongly-rezzed) external monitor.
I can’t figure out how, via AppleScript, to make the scrollable list of possible resolution and refresh-rate choices active, or to set the value to a specified desired combo of horizontal vertical and refresh. In the mean time I have incorporated the above-cited AppleScript into a QuicKeys macro followed by a pair of QK clicks — the first to make the scrollable list active so that I can use the arrow keys to switch to a different setting even in the dark, as it were, and confirm each change (even if it’s equally wrong) so I can keep going until I hit something the monitor can use. Klunky and awkward but functional.
Suggestions for a more elegant approach?
It would be nice to be able to bypass SysPrefs and issue something more imperative like
tell the application "System Events" activate set the display parameters of monitor 1 to "1024 x 768 x 32 @ 85" end tell
Except of course that it should work.
I can’t be the only person who has needed to AppleScript-coerce the monitor settings of their Mac. (It was common enough under MacOS 9). How’s it done?