Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Applescript/shell script] how could I change the images folder of the screen saver ?

103 views
Skip to first unread message

JiPaul

unread,
Sep 25, 2015, 3:45:06 AM9/25/15
to
Hello everybody,

The question is in the subject.
I've found how to start a screen saver with AS :
---------------------------
tell application "System Events"

set ss1 to screen saver "Arabesque"
set ss2 to screen saver "Flurry"
set ss3 to screen saver "Shell"
set ss4 to screen saver "iLifeslideshows"
set ss5 to screen saver "Word of the Day"
set ss6 to screen saver "iTunes Artwork"
set ss7 to screen saver "Computer Name"
set ss8 to screen saver "BOINCSaver"
start ss3 # (or ss1 or ss2...)

end tell
--------------------------------
But that I wish to do, for pictures-based sc savers (like
"iLifeslideshows"), is changing (by AS or shell script) the images
folder.
And also how to change the style of "iLifeslideshows" (origami, mosaic,
pictures wall, floating pictures, Ken Burns, and so on...) ?



--
JiPaul.
/ /--/--//\\ Jean-Paul Blanc
|/| L |\\\ quelquepart en (somewhere in)
\/|| = |||\\\ FRANCE

Jolly Roger

unread,
Sep 25, 2015, 11:30:12 AM9/25/15
to
On 2015-09-25, JiPaul <bl...@empty.org> wrote:
> Hello everybody,
>
> The question is in the subject.
> I've found how to start a screen saver with AS :
> ---------------------------
> tell application "System Events"
>
> set ss1 to screen saver "Arabesque"
> set ss2 to screen saver "Flurry"
> set ss3 to screen saver "Shell"
> set ss4 to screen saver "iLifeslideshows"
> set ss5 to screen saver "Word of the Day"
> set ss6 to screen saver "iTunes Artwork"
> set ss7 to screen saver "Computer Name"
> set ss8 to screen saver "BOINCSaver"
> start ss3 # (or ss1 or ss2...)
>
> end tell
> --------------------------------
> But that I wish to do, for pictures-based sc savers (like
> "iLifeslideshows"), is changing (by AS or shell script) the images
> folder.
>
> And also how to change the style of "iLifeslideshows" (origami, mosaic,
> pictures wall, floating pictures, Ken Burns, and so on...) ?

Unfortunately, you can't do that with pure AppleScript since Apple does
not provide AppleScript interfaces to change those properties. Here is
what Apple allows (found in the System Events dictionary):

screen saver n : an installed screen saver

elements
contained by application.

properties
displayed name (text, r/o) : name of the screen saver module as
displayed to the user
name (text, r/o) : name of the screen saver module to be displayed
path (alias, r/o) : path to the screen saver module
picture display style (text) : effect to use when displaying
picture-based screen savers (slideshow, collage, or mosaic)

responds to
start, stop.

screen saver preferences object n : screen saver settings

properties
delay interval (integer) : number of seconds of idle time before the
screen saver starts; zero for never
main screen only (boolean) : should the screen saver be shown only on
the main screen?
running (boolean, r/o) : is the screen saver running?
show clock (boolean) : should a clock appear over the screen saver?

responds to
start, stop.

Using the defaults command to read defaults for com.apple.screensaver
shows just two properties:

# defaults read com.apple.screensaver
{
askForPassword = 1;
askForPasswordDelay = 5;
}

I had a look at these screen saver preference files:

~/Library/Preferences/com.apple.screensaver.plist
~/Library/Preferences/ByHost/com.apple.screensaver.5387F4CD-305A-54DE-B565-463EEBFCF270.plist

(The "5387F4CD-305A-54DE-B565-463EEBFCF270" portion of the name of the
second file will differ on your system.)

The first property list file contains:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>askForPassword</key>
<integer>1</integer>
<key>askForPasswordDelay</key>
<real>5</real>
</dict>
</plist>

Not much there...

The second property list file contains:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CleanExit</key>
<string>YES</string>
<key>PrefsVersion</key>
<integer>100</integer>
<key>idleTime</key>
<integer>300</integer>
<key>moduleDict</key>
<dict>
<key>moduleName</key>
<string>iLifeSlideshows</string>
<key>path</key>
<string>/System/Library/Frameworks/ScreenSaver.framework/Resources/iLifeSlideshows.saver</string>
<key>type</key>
<integer>0</integer>
</dict>
</dict>
</plist>

So it appears the settings you want are stored elsewhere - not sure
where, though.

If you can find where OS X stores these settings, and if they are stored
in a property list (plist) file or another suitable text format, you
might be able to use a shell/Perl/whatever script to modify that file.

After making any change "under the hood" like this, you'd likely need to
restart the cfprefsd daemon with this command to make the changes take
effect:

# killall cfprefsd

--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.

JR

JiPaul

unread,
Sep 25, 2015, 1:49:18 PM9/25/15
to
Jolly Roger <jolly...@pobox.com> wrote:

> Unfortunately, you can't do that with pure AppleScript since Apple does
> not provide AppleScript interfaces to change those properties.

I've presumed that !...

> Here is
> what Apple allows (found in the System Events dictionary):
[snip...]
> responds to
> start, stop.

... because I've found that

But I thought asking this question here, that I could have some answer
or some idea...

And you give me one !...
Thanks a lot Jolly Roger ! :-)


> I had a look at these screen saver preference files:
>
> ~/Library/Preferences/com.apple.screensaver.plist
> ~/Library/Preferences/ByHost/com.apple.screensaver.5387F4CD-305A-54DE-B565-463
> EEBFCF270.plist

I've found these files... But I've found too the following file :
~/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.5B50CA07-B35D-5045-9F15-A185809EFCF3.plist

which is the one where are stored the settings I was looking for...
(perhaps you havn't it because you never uses this sc saver ?)

Of course I tried to modify these settings and to save this file... but
it didnt work because the system dont read it again and when the Sc
Saver start it rewrites the file !...

I presumed I have to restart some process for reread the prefs. But I
didn't know which one.

But now you give me the missing piece of the puzzle :

> After making any change "under the hood" like this, you'd likely need to
> restart the cfprefsd daemon with this command to make the changes take
> effect:
>
> # killall cfprefsd

And it works.

Thanks again :-)

Now I have to fix my script to do that. But isn't it some problem with
restarting this daemon every hour ?

Jolly Roger

unread,
Sep 25, 2015, 2:37:32 PM9/25/15
to
On 2015-09-25, JiPaul <bl...@empty.org> wrote:
>
> I've found too the following file :
> ~/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.5B50CA07-B35D-5045-9F15-A185809EFCF3.plist
>
> which is the one where are stored the settings I was looking for...
> (perhaps you havn't it because you never uses this sc saver ?)

Ah, I missed that one. Admittedly I wasn't looking very hard! : D

> Of course I tried to modify these settings and to save this file... but
> it didnt work because the system dont read it again and when the Sc
> Saver start it rewrites the file !...
>
> I presumed I have to restart some process for reread the prefs. But I
> didn't know which one.
>
> But now you give me the missing piece of the puzzle :
>
>> After making any change "under the hood" like this, you'd likely need to
>> restart the cfprefsd daemon with this command to make the changes take
>> effect:
>>
>> # killall cfprefsd
>
> And it works.
>
> Thanks again :-)

Welcome!

> Now I have to fix my script to do that. But isn't it some problem with
> restarting this daemon every hour ?

I don't think that should cause any issues; but if you do notice it
causing an issue, you can just refrain from restarting it so often. : )

JiPaul

unread,
Sep 25, 2015, 6:07:00 PM9/25/15
to
Jolly Roger <jolly...@pobox.com> wrote:

> I don't think that should cause any issues; but if you do notice it
> causing an issue, you can just refrain from restarting it so often. : )

OK. I'll see. :-)
And the script works now. No problem. :-)

Jolly Roger

unread,
Sep 25, 2015, 6:47:51 PM9/25/15
to
On 2015-09-25, JiPaul <bl...@empty.org> wrote:
> Jolly Roger <jolly...@pobox.com> wrote:
>
>> I don't think that should cause any issues; but if you do notice it
>> causing an issue, you can just refrain from restarting it so often. : )
>
> OK. I'll see. :-)
> And the script works now. No problem. :-)

Great! You should clean it up and post it for anyone else who wants to
do something like this. : )

JiPaul

unread,
Oct 7, 2015, 3:56:46 AM10/7/15
to
Jolly Roger <jolly...@pobox.com> wrote:

> Great! You should clean it up and post it for anyone else who wants to
> do something like this. : )

Actually I've had some problem with it. I think it's no ok killing
cfprefsd agent when the screensaver is activ or when the monitor is
sleeping.
So I know how to detect that the ScSav is activ. But how could I know
(by script of course) that the monitor is sleeping ? Have you an idea ?

Jolly Roger

unread,
Oct 7, 2015, 12:20:07 PM10/7/15
to
JiPaul <bl...@empty.org> wrote:
> Jolly Roger <jolly...@pobox.com> wrote:
>
>> Great! You should clean it up and post it for anyone else who wants to
>> do something like this. : )
>
> Actually I've had some problem with it. I think it's no ok killing
> cfprefsd agent when the screensaver is activ or when the monitor is
> sleeping.
> So I know how to detect that the ScSav is activ. But how could I know
> (by script of course) that the monitor is sleeping ? Have you an idea ?

I've used this command to see if the screen is asleep:

ioreg -n IODisplayWrangler | grep -i IOPowerManagement | perl -pe
's/^.*DevicePowerState\"=([0-9]+).*$/\1/'

If it returns 0, the screen is sleeping.

JiPaul

unread,
Oct 7, 2015, 3:16:00 PM10/7/15
to
Jolly Roger <jolly...@pobox.com> wrote:

> I've used this command to see if the screen is asleep:
>
> ioreg -n IODisplayWrangler | grep -i IOPowerManagement | perl -pe
> 's/^.*DevicePowerState\"=([0-9]+).*$/\1/'
>
> If it returns 0, the screen is sleeping.

OK. I'll test that. But later. Because I have some issues with El
Capitan now.
0 new messages