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.


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


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

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

Tell application "System Events" to start PhotoWall

The opposite of start is stop

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) :frowning:

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?

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”
tell application "System Events" 
 set the current screen saver to "Photo Wall"
#start current screen saver 
 end tell
  1. run this script. Optionally, delete the character # at the beginning of line 3 , to see a demo

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

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:

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:

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"

Thanks everyone! This is fantastic.