A screensaver to send your display to sleep.

I poked around a bit looking for something that did this, and couldn’t find anything, apart from some sample code using a private API to send the display to sleep, so I whacked that into a screeensaver.


This does use a private API and thus could do anything. No warranties, may destroy your machine, etc etc etc, but works for me.


//  SleepSaverView.m
//  SleepSaver
//  Created by Nigel Kersten on 1/29/09.
//  Copyright (c) 2009, Google Inc. All rights reserved.

#import "SleepSaverView.h"

@implementation SleepSaverView

- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
self = [super initWithFrame:frame isPreview:isPreview];
if (self) {
if (! isPreview) {
[self dimDisplayNow];
return self;

- (BOOL)hasConfigureSheet
return NO;

- (NSWindow*)configureSheet
return nil;

- (void) dimDisplayNow {
io_registry_entry_t r = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/IOResources/IODisplayWrangler");
if (r) {
IORegistryEntrySetCFProperty(r, CFSTR("IORequestIdle"), kCFBooleanTrue);


7 thoughts on “A screensaver to send your display to sleep.

  1. Very nice! Works as expected on all connected screens. Now, if you could make the screens fade out slowly while the computer sings “Daisy, Daisy, give me your answer do…”, *that* would be something.

  2. Excellent contribution. My previous “solution” of having script saver call a setuid shell script which in turn set the sleep timeout as low as possible, then back again left a lot to be desired.

  3. Looking for a solution to automatically sleeping display with a background process running (QuickTime Broadcaster). Your screensaver is close, but the cursor appears after 5-10 seconds of running. So, ideally don’t want the cursor displaying. Do you have any updates to this screensaver that fixes this issue?

  4. Also, I guess if there is a process running, the OS will never thing it is idle to activate your screensaver. Curious, what process controls the hot corner setting for “Sleep Display” or if you can modify the OS to ignore some applications running like QT Broadcaster to activate the screensaver?

  5. Well it depends on the kind of process. :)

    I use LockTight mainly to activate my screensaver, which uses the same method as the hot corners, which is another private API I believe.

  6. The process is QuickTime Broadcaster.

    Ok, LockTight looks interesting, but requires someone physically at the keyboard to hit the keyboard combo. I am looking for a solution that automatically sleeps the display when there is a application processing, again which is QuickTime Broadcaster. Screensavers never get activated because the OS settings determine the system isn’t idle because of this running application.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>