Note: This worklet changes the screensaver setting only for the current signed in user. The way this worklet was written creates a folder to save screensaver images to, and clears out that folder each time the worklet is run so you can add in new pictures if needed.
Evaluation:
Exit 1
Remediation:
#!/bin/sh
# Get user logged into console and put into variable "user"
user=`ls -l /dev/console | cut -d " " -f 4`
#Creates a /Library/Backgrounds folder if there is not one already
mkdir -p /Library/Backgrounds
# Removes the previously saved screensavers in the background folder
rm -rf /Library/Backgrounds/*
# This is where the new screensavers are referenced, add/remove as necessary
# Each image lasts for 5 seconds, so for a longer time, copy the image a few times
scp screensaver1.png "/Library/Backgrounds/"
scp screensaver2.png "/Library/Backgrounds/"
scp screensaver3.png "/Library/Backgrounds/"
scp screensaver4.png "/Library/Backgrounds/"
scp screensaver5.png "/Library/Backgrounds/"
scp screensaver6.png "/Library/Backgrounds/"
scp screensaver7.png "/Library/Backgrounds/"
scp screensaver8.png "/Library/Backgrounds/"
#This section sets the preferences to use for screen savers.
sudo -u $user defaults -currentHost write com.apple.screensaver CleanExit -string "YES"
sudo -u $user defaults -currentHost write com.apple.screensaver PrefsVersion -int 100
sudo -u $user defaults -currentHost write com.apple.screensaver showClock -string "NO"
#This idle time is counted as seconds, change the 600 (10 minutes) as needed.
sudo -u $user defaults -currentHost write com.apple.screensaver idleTime -int 600
sudo -u $user defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName -string "iLifeSlideshows" path -string "/System/Library/Frameworks/ScreenSaver.framework/Resources/iLifeSlideshows.saver" type -int 0
sudo -u $user defaults -currentHost write com.apple.screensaver tokenRemovalAction -int 0
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser LastViewedPhotoPath -string ""
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedFolderPath -string "/Library/Backgrounds"
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser ShufflesPhotos -bool false
sudo -u $user defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "Classic"
sudo killall -hup cfprefsd
Upload the images you want to use, if you don’t want to use the “screensaver_” naming scheme, be sure to use the correct image names where the new images are referenced.