Like quite a few Mac users, my iMac lives right beside my bed, and though this is great, I like turning the display off when I go to sleep. For the longest time, every night I would go to System Preferences -> Energy Saver and slide the time down to 1 minute, and then back to 45 minutes in the morning. Although I've seen this hint, which does the changing for you, for the occasional time when I would sleep my display then realize I wanted to check something, I'd have to run the script again (or worse, wait 90 seconds, then run it).
Finally, however, I've come up with a simple solution using Butler and GeekTool: one keystroke to toggle between my two settings, and an unobtrusive 45 or 1 in the bottom corner of the screen.
First off, in Butler add a new AppleScript smart item, and paste this in as the source:
set thetime to ¬
(do shell script ¬
"pmset -g | grep displaysleep | awk '{ print $2; }'") ¬
as number
if thetime is 1 then
set thetime to 45
else
set thetime to 1
end if
do shell script ("pmset dim " & thetime) password ¬
"YOURPASSWORDHERE" with administrator privileges
Replace YOURPASSWORDHERE with either your admin password, or for the more security-aware, just remove the password "YOURPASSWORDHERE" part, and it will prompt you each time. Next, set a keyboard trigger for the AppleScript. I'm using F16, because it's right next to the dim/brighten buttons.
pmset -g | grep displaysleep | awk '{ print $2; }'
Position it to your liking and choose a font (I did white/Arial). That's it! Toggling your screen's display time is just a keyboard stroke away!
Mac OS X Hints
http://hints.macworld.com/article.php?story=20060724134300315