9

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:

enter image description here

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:

enter image description here

Any ideas why it wouldn't work on a pristine mac?

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
  • Where is programming in this question? – riodoro1 Mar 31 '15 at 17:52
  • @riodoro1 we wrote the app that install Ninja.saver by copying it to ~/Library/Screen Savers. We are looking into what other actions we need to perform to properly install a screensaver on MacOSX (on a pristine machine). – Pablo Fernandez Mar 31 '15 at 17:56
  • 1
    @riodoro1 I can copy and paste the code we use to copy the file if that makes you happy, but is very trivial code. – Pablo Fernandez Mar 31 '15 at 17:58
  • 4
    I see that the question has been marked to be moved to super user, I don't see how superuser is a better site for this sort of questions than stack overflow. – Pablo Fernandez Mar 31 '15 at 18:02

1 Answers1

1

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.

Craig Roberts
  • 171
  • 1
  • 4
  • 18