Sometimes it’d be nice to be able to put just your Mac’s display to sleep, without knocking out the entire machine. For example, say you’ve scheduled a backup utility to run in the middle of the night. You want your Mac to wake up (and then, when it’s done, put itself back to sleep). But you don’t want its screen to be blazing away the whole time.
If you were sitting at the keyboard, you could press Shift-Control-Eject to sleep the screen. But what if (as in the scenario above) you’re not at your keyboard when you want the screen alone to sleep? MacOSXHints.com reader Lutzifer has an AppleScript that could help.
This hint uses AppleScript and the Active Screen Corners feature of Exposé to sleep the screen. The script moves the mouse cursor to the top left corner of the screen; that mouse movement tells Exposé to put the screen to sleep.
To start, in the Active Screen Corners section of the Exposé preference pane, set the top-left corner to Put Display to Sleep. Then, open the Applescript Editor and copy-and-paste the following script into it:
do shell script "python -c "import objc;bndl = objc.loadBundle('CoreGraphics', globals(), '/System/Library/Frameworks/ApplicationServices.framework');objc.loadBundleFunctions(bndl, globals(),[('CGWarpMouseCursorPosition', 'v{CGPoint=ff}')]);CGWarpMouseCursorPosition((0, 0));""tell application "Finder" to activate
That done, you can now sleep the screen by invoking the script however you wish. In the case of that middle-of-the-night backup, for example, you could create a recurring iCal event, starting a minute or two after your Mac wakes up to start the backup. Select Run Script from that event’s Alarm drop-down and select the script above.
The one downside to this technique is that, if your mouse ever ventures into the upper-left corner (to open the Apple menu, say), you’ll sleep your screen. If that’s too much of a hassle for you, you could check out a utility called Sleep Display.