Friday, December 15, 2017

#1 2017-11-27 10:34:48 am

thePUNCH
Member
From:: NC
Registered: 2005-03-26
Posts: 89

Changing Screensaver

Hi all,

I'm trying to create a script to change my screensaver to Photo Wall when I log in. Figured I'd try w/ GUI scripting. But am open to other ideas as well. I found a script that targets the Sharing pane, and checks a checkbox. But I don't know how to 1) select the Screen Saver tab in Desktop & Screen Saver prefs, and 2) select Photo Wall from the tiles on the left.

Any help would be appreciated.

Applescript:


tell application "System Preferences"
   activate
end tell

tell application "System Events"
   tell process "System Preferences"
       click menu item "Desktop & Screen Saver" of menu "View" of menu bar 1
       delay 2
       tell window "Desktop & Screensaver"
           click tab 0
           delay 1
       end tell
   end tell
end tell

Offline

 

#2 2017-11-27 11:59:38 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 541
Website

Re: Changing Screensaver

Hi thePUNCH
Get all screen savers: (optional: remove the #)

Applescript:

Tell application "System Events" to set allScreensaver to name of every screen saver #whose name is "Photo Wall"

Or, define the variable: PhotoWall = name of your screen saver

Applescript:

Tell application "System Events" to start PhotoWall

The opposite of start is stop

Offline

 

#3 2017-11-27 02:48:54 pm

thePUNCH
Member
From:: NC
Registered: 2005-03-26
Posts: 89

Re: Changing Screensaver

Great. Thanks. This should work - was hoping to actually just set the screensaver to Photo Wall - so that when it did come on throughout the day, it would be that one. It resets to Flurry when I restart (a profile that is installed on my machine is setting it) sad

However, it doesn't return Photo Wall. When I run your script, and use one of the other screensavers (e.g. Random, Flurry, etc.) it returns that one. But it isn't doing that for Photo Wall. Wonder if it's technically called something else?

Offline

 

#4 2017-11-27 04:15:05 pm

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 541
Website

Re: Changing Screensaver

Try this:
1) run the script in my first post, to get all available screen saver (names)
2) copy & paste the result (the exact name of your  "Photo Wall" - screen saver)  at the end of the 2nd line below, replace "Photo Wall"

Applescript:

tell application "System Events"
set the current screen saver to "Photo Wall"
#start current screen saver
end tell

3) run this script. Optionally, delete the character # at the beginning of line 3 , to see a demo

Offline

 

#5 2017-11-27 05:56:48 pm

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4454

Re: Changing Screensaver

System Events's start command needs a screen saver specifier, not just a name. For instance:

Applescript:

tell application "System Events" to start screen saver "Flurry"

It's more complicated with Photo Wall. It's a style of "iLifeSlideShows". This seems to work for an immediate launch:

Applescript:

set pictureFolderPath to "/Library/Screen Savers/Default Collections/1-National Geographic" -- Or some other folder containing pictures.
set displayStyle to "PhotoWall"

do shell script ("defaults -currentHost write 'com.apple.ScreenSaverPhotoChooser' 'SelectedFolderPath' " & quoted form of pictureFolderPath & linefeed & ¬
   "defaults -currentHost write 'com.apple.ScreenSaver.iLifeSlideShows' 'styleKey' " & quoted form of displayStyle)

tell application "System Events" to start screen saver "iLifeSlideShows"

To set Photo Wall as the default screen saver looks to be something like the following, but I can't get it to work at the moment. Presumably some process needs to be 'killall'-ed to make the settings stick. Edit: Ach! I'm a dingbat! System Events itself can set the preferred screen saver (as Joy wrote in the post above). New script below:

Applescript:

set pictureFolderPath to "/Library/Screen Savers/Default Collections/1-National Geographic" -- Or some other folder containing pictures.
set displayStyle to "PhotoWall"

do shell script ("defaults -currentHost write 'com.apple.ScreenSaverPhotoChooser' 'SelectedFolderPath' " & quoted form of pictureFolderPath & linefeed & ¬
   "defaults -currentHost write 'com.apple.ScreenSaver.iLifeSlideShows' 'styleKey' " & quoted form of displayStyle)

tell application "System Events" to set current screen saver to screen saver "iLifeSlideShows"

Last edited by Nigel Garvey (2017-11-28 04:17:27 am)


NG

Offline

 

#6 2017-11-28 01:28:57 pm

thePUNCH
Member
From:: NC
Registered: 2005-03-26
Posts: 89

Re: Changing Screensaver

Thanks everyone! This is fantastic.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)