tags:

views:

186

answers:

2

Is there a Api, that can lock the screen as the menu thing you can add from keychain preferences?

A: 

I don't see anything documented as such, but the menu uses the ScreenSaver framework, which defines this:

@interface ScreenSaverDefaults : NSUserDefaults 
{
@private
    NSMutableDictionary     *_defaults;
    NSMutableDictionary     *_registeredDefaults;
    NSString                *_userName;
    NSString                *_domainName;
    BOOL                    _dirty;
    BOOL                    _screenLockPrefChanged;
}

+ (id) defaultsForModuleWithName:(NSString *)inModuleName;

@end
Azeem.Butt
A: 

To lock the screen, call:

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

Preston