Setting Screensaver picture and style

sam_hummerstone
New Contributor II

Hi Guys,

I have spent ages trying to get together a way of setting the screensaver to a company picture. I've tried scripts and Screensaver packages created in composer, configuration profiles, I can't seem to find a solution. Can someone suggest to me what might work? I will put the script I've been using down below just in case I'm doing it wrong.

#!/bin/sh
currentUser=`ls -l /dev/console | cut -d " " -f 4`

# grab the system's uuid
if [[ `ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-50` != "00000000-0000-1000-8000-" ]]; then
    macUUID=`ioreg -rd1 -c IOPlatformExpertDevice | grep -i "UUID" | cut -c27-62`
fi

jamf displayMessage -message $currentUser

defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist CleanExit "YES"
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist PrefsVersion -int 100
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist idleTime -int 600
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist moduleDict -dict moduleName "iLifeSlideshows" path "/System/Library/Frameworks/ScreenSaver.framework/Resources/iLifeSlideshows.saver" type -int 0
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist tokenRemovalAction -int 0
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist LastViewedPhotoPath ""
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist SelectedFolderPath "/Library/Screen Savers/Default Collections/5-custom"
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist SelectedSource -int 3
defaults write /Users/$curUser/Library/Preferences/ByHost/com.apple.ScreenSaver.iLifeSlideShows.$macUUID styleKey "KenBurns"

killall cfprefsd
1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

The main issue is that your first line you are getting currentUser, but later in the script you are trying to write to curUser so you have the wrong variable for all your commands, which is why its not writing any of the defaults commands to the plists.

Other thing is, if this script is run by a Casper policy, you're not correcting the permissions on the plist files after all those defaults write commands. The plists are likely becoming owned by root and the user account can't read them so it is probably creating a new stock plist to use.

Try fixing the variable and also adding these lines at the end

chown $currentUser /Users/$currentUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist
chown $currentUser /Users/$currentUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist
chmod 700 /Users/$currentUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist
chmod 700 /Users/$currentUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist

View solution in original post

3 REPLIES 3

bentoms
Release Candidate Programs Tester

@sam.hummerstone There's a few things that make screen saver tricky.

Only .slideSaver screen savers work at the login window as per this article.

I have had success modifying Save Hollywood with a video, but as per the above this does not work at the login window.

I believe this method (hat tip to @gregneagle) may still work & should also work at the login window.

Once you have a screen saver using either of the above, you can then set it via a Config Profile. At least that has been my experience.

mm2270
Legendary Contributor III

The main issue is that your first line you are getting currentUser, but later in the script you are trying to write to curUser so you have the wrong variable for all your commands, which is why its not writing any of the defaults commands to the plists.

Other thing is, if this script is run by a Casper policy, you're not correcting the permissions on the plist files after all those defaults write commands. The plists are likely becoming owned by root and the user account can't read them so it is probably creating a new stock plist to use.

Try fixing the variable and also adding these lines at the end

chown $currentUser /Users/$currentUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist
chown $currentUser /Users/$currentUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist
chmod 700 /Users/$currentUser/Library/Preferences/ByHost/com.apple.screensaver.$macUUID.plist
chmod 700 /Users/$currentUser/Library/Preferences/ByHost/com.apple.ScreenSaverPhotoChooser.$macUUID.plist

sam_hummerstone
New Contributor II

@mm2270 That seems to have done it, I stupidly copied code without reading the variables set!

As for @bentoms, that looks very interesting, may experiment when I have time this week!