Is there an API, that can lock the screen as the menu bar entry you can add from Keychain preferences?
This Keychain function is (was) locking the screen but not bringing the system to sleep.
Is there an API, that can lock the screen as the menu bar entry you can add from Keychain preferences?
This Keychain function is (was) locking the screen but not bringing the system to sleep.
To lock the screen, call:
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
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