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.
https://sites.google.com/a/explanatorygap.net/misc-sw/files/SleepSaver.saver.zip
This does use a private API and thus could do anything. No warranties, may destroy your machine, etc etc etc, but works for me.
code:
//
// 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);
IOObjectRelease(r);
}
}
@end
