- have a screen saver that sleeps the display instead of drawing pretty pictures on it.
- be prompted for your password when you disturb the screen saver.
- be able to immediately start your screen saver via your keyboard if you want to safely walk away from your computer.
- be able to temporarily disable your screen saver while watching a movie etc.
The sleepy screen saver
I've always wanted my screen saver to just put the display to sleep, but that's not been an OS X option out of the box.This hint comment offers some C code for sleeping the display immediately, which it seems is the only way to do it from the command line! There's the CTRL-SHIFT-Eject keystroke, but AppleScript cannot emulate the Eject keystroke. You can compile that code (change the function name to main) with
gcc -framework CoreFoundation -framework IOKit
if you've installed the XCode tools.Now you have an executable that just sleeps the display.
Why use a screen saver at all?
A fine question. I could just set my display to sleep before my screen saver starts. There's a reason.Phil has got me thinking about security recently, so I want my laptop to prompt for a password when someone wakes the display from sleep/disturbs the screen saver. This is easy to setup for the screen saver, but not so much for waking display. The best alternative I can find is SleepWatcher, but that project seems a little too fragile for me to depend on it. It would let me execute a script when the display wakes, but I also don't want to write a script that emulates the password prompt.
So I'm using a screen saver because I want the password prompt aspect.
How to make the application a screen saver
There are tutorials for making screen savers, and XCode even has a project for them (under Standard Apple Plug-ins), but I don't know Objective-C and there's more function stubs to fill out than I'd like. So I'm going to cheat and use ScriptSaver instead. It only runs AppleScripts, so we use a simple little script to invoke our executable according to this note. I put my executable in /usr/local/bin and made a /usr/local/AppleScripts directory for my script. Check your PATHs and such.Final touches
- I made sure, in the Security preference pane, that a password is required to wake this computer from sleep or screen saver.
- I use Quicksilver, because I prefer the keyboard to the mouse. OS X lets you use a Hot Corner for invoking the screen saver, but that's hard to activate with the keyboard... so I added /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app to Quicksilver's catalog. That way I can invoke the screen saver just like any other program. (Phil pointed me to this hint; if you don't want to install Quicksilver.)
- Temporarily disabling the screen saver for movies and such is comparable to disabling sleep, but it's a bit more complicated (see HippoMan's post at 12-31-2008, 08:26 PM for the solution – also, applaud him for politely putting up with a lot of stupid responses in that thread).
2 comments:
Whew, that seems like a lot of work. What are the reasons for doing this instead of just putting the computer to sleep?
Also, my settings are such that when the display goes to sleep, the screen locks.
(I'll delete your comment; let's see if you continue to get replies.)
Mine doesn't lock when the display sleeps - in the case where the display sleep is at 1 minute and the screen saver is at 3 minutes.
One improvement over sleeping the computer is I don't have to hear that CD drive do whatever the hell it does to make that noise. I assume there's mechanical wear involved.
Another: I might be downloading or something. Perhaps streaming audio. Compiling even.
Post a Comment