We wrote an application, Screensaver Ninja, that installs an screensaver for the user by copying it to ~/Library/Screen Savers. This works fine in my machine and the other developer's machine but in a testing machine I have, the file is there, if I let the screensaver activate, it selects it, but it doesn't appear on the list:
This is the code we use to install it:
func install() {
var err: NSError?
fileManager.copyItemAtURL(saverPackageUrl!, toURL: screensaversUrl!.URLByAppendingPathComponent("Ninja.saver"), error: &err)
if err != nil {
NSLog("Error installing Screensaver Ninja: \(err)")
}
}
and this is how we select it as default:
func setAsDefault() {
var mutable: NSMutableDictionary
if let moduleDict = CFPreferencesCopyAppValue("moduleDict", "com.apple.screensaver") as? NSDictionary {
mutable = moduleDict.mutableCopy() as NSMutableDictionary
} else {
mutable = NSMutableDictionary()
}
mutable.removeObjectForKey("displayName")
mutable["moduleName"] = "Ninja"
mutable["path"] = saverPath
mutable["type"] = 0
CFPreferencesSetValue("moduleDict", mutable as CFPropertyList, "com.apple.screensaver", kCFPreferencesCurrentUser, kCFPreferencesCurrentHost)
CFPreferencesAppSynchronize("com.apple.screensaver")
}
This is how it looks in my own machine (what I expected) after running that code:
Any ideas why it wouldn't work on a pristine mac?
Click the System Preferences menu item. Click the “Desktop & Screen Saver” icon. Click the Screen Saver tab. Select any screen saver in the column on the left.
Go to Settings > Personalization. Click on Lock screen and click on Screen caver settings link. Select your preferred screensaver and Wait time. Check the box behind On resume, display logon screen.
Open System and Preferences > Desktop & Screen Saver > Desktop tab. Now, scroll and try to find the previous image you used for the wallpaper. Select the image, and it will be set for the background once more.
What are the permissions for the Test user (could they be non-admin?) vs those for you and other Developers (I bet Admin or root)?
Use chmod 777 filename might fix it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With