以编程方式更改屏幕锁定超时 [英] Programmatically changing screen lock timeout
本文介绍了以编程方式更改屏幕锁定超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Cocoa应用程序中,我想访问和更改计算机的屏幕锁定超时设置.在系统偏好设置"中进行更改不需要用户输入管理员密码.
In my Cocoa application I would like to access and change the computer's screen lock timeout setting. Changing it in System Preferences does not require the user to enter the admin password.
不幸的是,我在文档中找不到任何信息,而且我不确定应该关注哪个主题(安全设置/prefPane编程).
任何帮助将不胜感激.
Unfortunately I couldn't find any information in the documentation, and I'm not sure what topic I should look into (security settings / prefPane programming).
Any help would be appreciated.
推荐答案
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/Users/new/Library/Preferences/com.apple.screensaver.plist"];
[plistDict setObject:@"1" forKey:@"askForPassword"];
[plistDict setObject:@"3600" forKey:@"askForPasswordDelay"];
[plistDict writeToFile:@"/Users/new/Library/Preferences/com.apple.screensaver.plist" atomically:YES];
或从终端
defaults write com.apple.screensaver askForPasswordDelay 5
这篇关于以编程方式更改屏幕锁定超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文