Re: Programmatically change screen saver settings
Re: Programmatically change screen saver settings
- Subject: Re: Programmatically change screen saver settings
- From: Juanjo Conti <email@hidden>
- Date: Sun, 01 Mar 2015 09:48:05 -0300
I was able to do it this way.
Reading:
var moduleDict = CFPreferencesCopyAppValue("moduleDict",
"com.apple.screensaver") as NSDictionary
var saverName = moduleDict["moduleName"] as String!
Writing:
var moduleDict = CFPreferencesCopyAppValue("moduleDict",
"com.apple.screensaver") as NSDictionary
var mutable = moduleDict.mutableCopy() as NSMutableDictionary
mutable["moduleName"] = "MyScreenSaver"
mutable["path"] = mySaverPath
CFPreferencesSetValue("moduleDict", mutable as CFPropertyList,
"com.apple.screensaver", kCFPreferencesCurrentUser,
kCFPreferencesCurrentHost)
CFPreferencesAppSynchronize("com.apple.screensaver")
On Sat, Feb 28, 2015 at 10:50 PM, <email@hidden>
wrote:
> You should read the docs and expect that some domains may require admin
> rights or even possibly not be accessible by design.
>
> From CFPreferences docs
>
> Note that modification of some preferences domains (those not belonging to
> the “Current User”) requires root privileges (or Admin privileges prior to
> OS X v10.6)—see *Authorization Services Programming Guide
> <https://developer.apple.com/library/mac/documentation/Security/Conceptual/authorization_concepts/01introduction/introduction.html#//apple_ref/doc/uid/TP30000995>* for
> information on how to gain suitable privileges.
>
> Sent from my iPhone
>
> On 2015/03/01, at 10:23, Juanjo Conti <email@hidden> wrote:
>
> Sorry, my code is Swift. There is no @"strings".
>
> On Sat, Feb 28, 2015 at 10:14 PM, Graham Cox <email@hidden>
> wrote:
>
>
> On 1 Mar 2015, at 12:46 am, Juanjo Conti <email@hidden>
>
> wrote:
>
>
> This settings are not accesibles via NSUserDefaults but they are via CF.
>
>
> I was able to do this by code
>
>
> var moduleDict = CFPreferencesCopyAppValue("moduleDict",
>
> "com.apple.screensaver") as CFDictionary
>
>
> but when I try to get one value from that "dict" the program crash in
>
> this
>
> line:
>
>
> var saverName = CFDictionaryGetValue(moduleDict, "moduleName")
>
>
>
>
> You're trying to use a C string as a key, not a CFString. Try
>
> @"moduleDict" instead.
>
>
>
> --Graham
>
>
>
>
>
>
> --
>
> Juanjo Conti <jjconti <http://goog_2023646312>@carouselapps.com
> <email@hidden>>
>
> Software Engineer - Carousel Apps <https://carouselapps.com>
>
> --
> Carousel Apps Limited, registered in England & Wales with registered
> number
> 7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
> Street, London SE1 3HN. Any communication sent by or on behalf of Carousel
> App Ltd or any of its subsidiary, holding or affiliated companies or
> entities (together "Watu") is confidential and may be privileged or
> otherwise protected. If you receive it in error please inform us and then
> delete it from your system. You should not copy it or disclose its
> contents
> to anyone. Messages sent to and from Watu may be monitored to ensure
> compliance with our internal policies and to protect our business. Emails
> are not secure and cannot be guaranteed to be error free. Anyone who
> communicates with us by email is taken to accept these risks.
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
>
--
Juanjo Conti <jjconti <http://goog_2023646312>@carouselapps.com
<email@hidden>>
Software Engineer - Carousel Apps <https://carouselapps.com>
--
Carousel Apps Limited, registered in England & Wales with registered number
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel
App Ltd or any of its subsidiary, holding or affiliated companies or
entities (together "Watu") is confidential and may be privileged or
otherwise protected. If you receive it in error please inform us and then
delete it from your system. You should not copy it or disclose its contents
to anyone. Messages sent to and from Watu may be monitored to ensure
compliance with our internal policies and to protect our business. Emails
are not secure and cannot be guaranteed to be error free. Anyone who
communicates with us by email is taken to accept these risks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden