Previously the script below from another message made it possible to have custom screensaver files (Photos) that would rotate. This no longer works in macOS Sonoma. Does anyone know a new method to have the screensaver call photos from a particular folder in somona via a script or another way.
#!/bin/sh
## get current user
user=`ls -l /dev/console | cut -d " " -f 4`
## get macOS version(s)
osMajor=$(/usr/bin/sw_vers -productVersion | /usr/bin/awk -F"." '{print $2}')
osMinor=$(/usr/bin/sw_vers -productVersion | /usr/bin/awk -F"." '{print $3}')
## set key items for screensaver
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver CleanExit -string "YES"
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver PrefsVersion -int 100
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver showClock -string "NO"
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver idleTime -int 60
## configure screensaver framework based on macOS version
if [[ $osMajor -eq 14 ]] && [[ $osMinor -ge 2 ]]; then
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName -string "iLifeSlideshows" path -string "/System/Library/Frameworks/ScreenSaver.framework/PlugIns/iLifeSlideshows.appex" type -int 0
else
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName -string "iLifeSlideshows" path -string "/System/Library/Frameworks/ScreenSaver.framework/Resources/iLifeSlideshows.saver" type -int 0
fi
## additional configuration settings for screensaver framework
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.screensaver tokenRemovalAction -int 0
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser LastViewedPhotoPath -string ""
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedFolderPath -string "/Users/Shared/Screensaver"
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.ScreenSaverPhotoChooser ShufflesPhotos -bool "false"
/usr/bin/sudo -u $user /usr/bin/defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "Classic"
/usr/bin/sudo /usr/bin/killall -hup cfprefsd
exit 0
Doesnt work at all, its is ignoring my base64 settings for the wallpaper and screensaver and setting Sonoma for both.
Hey @tkimpton,
This has worked for me in testing. This script will only set the screensaver. There is a different script in the MacAdmins chat to set the wallpaper as well.
Hey @tkimpton,
This has worked for me in testing. This script will only set the screensaver. There is a different script in the MacAdmins chat to set the wallpaper as well.
@mattcherson ive tested this in my test environment a ridiculous amount of times and it doesnt work for me. iscreensaver does work and i can verify on that.
Several thoughts:
- As described Here the base64-encoded binary plist stores the absolute path name to the screensaver file; this means that if the .saver file is stored in /Users/[username]/Library/Screen Savers/ you would have to recreate the plist file for every individual user. To avoid that, you would want to install it to /Library/Screen Savers/ instead.
- If the .saver file is not code-signed and notarized, it may have file attributes inside it which put it in quarantine. You can try xattr -rc /path/to/screensaver to clear the quarantine flags.
- If you just need to get something working today, you can do a test using iScreensaver (Download link: https://iscreensaver.com/downloads.shtml ) which offers an unlimited free demonstration trial, 30 day money back guarantee upon purchasing. iScreensaver 6.8.6 and higher automatically solve all these issues for macOS Sonoma.
Several thoughts:
- As described Here the base64-encoded binary plist stores the absolute path name to the screensaver file; this means that if the .saver file is stored in /Users/[username]/Library/Screen Savers/ you would have to recreate the plist file for every individual user. To avoid that, you would want to install it to /Library/Screen Savers/ instead.
- If the .saver file is not code-signed and notarized, it may have file attributes inside it which put it in quarantine. You can try xattr -rc /path/to/screensaver to clear the quarantine flags.
- If you just need to get something working today, you can do a test using iScreensaver (Download link: https://iscreensaver.com/downloads.shtml ) which offers an unlimited free demonstration trial, 30 day money back guarantee upon purchasing. iScreensaver 6.8.6 and higher automatically solve all these issues for macOS Sonoma.
@iScreensaver thanks very much :)
Several thoughts:
- As described Here the base64-encoded binary plist stores the absolute path name to the screensaver file; this means that if the .saver file is stored in /Users/[username]/Library/Screen Savers/ you would have to recreate the plist file for every individual user. To avoid that, you would want to install it to /Library/Screen Savers/ instead.
- If the .saver file is not code-signed and notarized, it may have file attributes inside it which put it in quarantine. You can try xattr -rc /path/to/screensaver to clear the quarantine flags.
- If you just need to get something working today, you can do a test using iScreensaver (Download link: https://iscreensaver.com/downloads.shtml ) which offers an unlimited free demonstration trial, 30 day money back guarantee upon purchasing. iScreensaver 6.8.6 and higher automatically solve all these issues for macOS Sonoma.
Hey @iScreensaver ,
Thank you for this!
In my testing I did have the .saver file saving to /Library/Screen Savers/
So that might be why it was working in my instance
Hey @iScreensaver ,
Thank you for this!
In my testing I did have the .saver file saving to /Library/Screen Savers/
So that might be why it was working in my instance
There's also some evidence that not only do you need to set the new Sonoma plist located at ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist
You must also set up the old (pre-Sonoma) plist like this
defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName "MyScreensaver" path "/Library/Screen Savers/MyScreensaver.saver" type 0
Note that both of these would need to be set for each user account.
Hi all,
What if I just want to put the classic Sonoma wallpaper to the desktop and login? How would I script that?

thanks :)
If anyone is still looking to configure/deploy screensavers on Sonoma, the solution put forth by Marc Bevin is working as of Sonoma 14.3.
If anyone is still looking to configure/deploy screensavers on Sonoma, the solution put forth by Marc Bevin is working as of Sonoma 14.3.
I will have to test that out. thanks.
If anyone is still looking to configure/deploy screensavers on Sonoma, the solution put forth by Marc Bevin is working as of Sonoma 14.3.
What kind of solution he offered. Where can I see it?
What kind of solution he offered. Where can I see it?
Review the entire topic and look for the entries from Marc Bevin. If you test it before me, let me know how it goes.
Hey All,
I have found the following scripts on the MacAdmin slack channel that seem to work.
Basically, there are two steps that need to be completed.
Step 1: Set the Screensaver on a test device manually and run the following script to pull the Base64 code of the settings:
#!/bin/bash
loggedInUser=$(/usr/bin/stat -f%Su /dev/console)
wallpaper_store_path="/Users/${loggedInUser}/Library/Application Support/com.apple.wallpaper/Store/Index.plist"
getWallpaperBase64=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | awk '/<data>/,/<\\/data>/' | xargs | tr -d " " | tr "<" "\\n" | head -2 | tail -1 | cut -c6-)
echo "wallpaperBase64: ${getWallpaperBase64}"
getWallpaperLocation=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | grep -A 2 "relative" | head -2 | tail -1 | xargs | cut -c9- | rev | cut -c10- | rev)
echo "wallpaperLocation: ${getWallpaperLocation}"
getScreensaverBase64=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | awk '/<data>/,/<\\/data>/' | xargs | tr -d " " | tr "<" "\\n" | tail -2 | head -1 | cut -c6-)
echo "screensaverBase64: ${getScreensaverBase64}"
Step 2: From there, update lines 9 & 10 with the Base64 code that we just got, and then push out the following script in a policy:
#!/bin/bash
# Do not edit these variables.
loggedInUser=$(/usr/bin/stat -f%Su /dev/console)
wallpaper_store_path="/Users/${loggedInUser}/Library/Application Support/com.apple.wallpaper/Store"
current_RFC3339_UTC_date="$(date -u '+%FT%TZ')"
# Input the data from the 'Get Screen Saver and Wallpaper Settings' script to the variables below.
wallpaperBase64='YOUR_BASE64_CODE_HERE'
screensaverBase64='YOUR_BASE64_CODE_HERE'
# Index.plist contents.
aerial_desktop_and_screensaver_settings_plist="$(plutil -create xml1 - |
plutil -insert 'Desktop' -dictionary -o - - |
plutil -insert 'Desktop.Content' -dictionary -o - - |
plutil -insert 'Desktop.Content.Choices' -array -o - - |
plutil -insert 'Desktop.Content.Choices' -dictionary -append -o - - |
plutil -insert 'Desktop.Content.Choices.0.Configuration' -data "${wallpaperBase64}" -o - - |
plutil -insert 'Desktop.Content.Choices.0.Files' -array -o - - |
plutil -insert 'Desktop.Content.Choices.0.Provider' -string 'com.apple.wallpaper.choice.aerials' -o - - |
plutil -insert 'Desktop.Content.Shuffle' -string '$null' -o - - |
plutil -insert 'Desktop.LastSet' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Desktop.LastUse' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Idle' -dictionary -o - - |
plutil -insert 'Idle.Content' -dictionary -o - - |
plutil -insert 'Idle.Content.Choices' -array -o - - |
plutil -insert 'Idle.Content.Choices' -dictionary -append -o - - |
plutil -insert 'Idle.Content.Choices.0.Configuration' -data "${screensaverBase64}" -o - - |
plutil -insert 'Idle.Content.Choices.0.Files' -array -o - - |
plutil -insert 'Idle.Content.Choices.0.Provider' -string 'com.apple.wallpaper.choice.screen-saver' -o - - |
plutil -insert 'Idle.Content.Shuffle' -string '$null' -o - - |
plutil -insert 'Idle.LastSet' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Idle.LastUse' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Type' -string 'individual' -o - -)"
# Create the path to the screen saver/wallpaper Index.plist.
mkdir -p "${wallpaper_store_path}"
# Create the Index.plist
plutil -create binary1 - |
plutil -insert 'AllSpacesAndDisplays' -xml "${aerial_desktop_and_screensaver_settings_plist}" -o - - |
plutil -insert 'Displays' -dictionary -o - - |
plutil -insert 'Spaces' -dictionary -o - - |
plutil -insert 'SystemDefault' -xml "${aerial_desktop_and_screensaver_settings_plist}" -o "${wallpaper_store_path}/Index.plist" -
# Kill the wallpaperAgent to refresh and apply the screen saver/wallpaper settings.
killall WallpaperAgent
Make sure to also package up the images to the location that was set on the test device as well
Thanks for posting this! I followed the steps as provided in the Mac Admins Slack post and the settings were changed as expected on my test Mac and on my production Mac.
Thanks Marc works great for setting both. Is there a way to only just set the screensaver? We have corporate marketing just wishing to change screensavers now and again and users go mental about faffing with their wallpaper.
The solution from Mac Admins that @mattcherson posted has been working for me, but some of my test users have reported either no change in screen saver behavior, and I also noticed on my own MacBook Pro that the wallpaper was reset to the default for Sonoma. I used the version of the script that preserves the user's wallpaper setting. At my company the communications team creates several images that we deploy using a package to /Library/Screen Savers/Default Collections/FolderName (where "FolderName" is the name of the folder containing the images"). I keep thinking that Apple really doesn't want us to change screen saver behavior with a script and they keep mucking up our processes just for fun. I did also notice that our process we still use for macOS Ventura doesn't work either on occasion even though the policy log shows no errors, and simply re-running the policy solves the issue.
Hey All,
I have found the following scripts on the MacAdmin slack channel that seem to work.
Basically, there are two steps that need to be completed.
Step 1: Set the Screensaver on a test device manually and run the following script to pull the Base64 code of the settings:
#!/bin/bash
loggedInUser=$(/usr/bin/stat -f%Su /dev/console)
wallpaper_store_path="/Users/${loggedInUser}/Library/Application Support/com.apple.wallpaper/Store/Index.plist"
getWallpaperBase64=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | awk '/<data>/,/<\\/data>/' | xargs | tr -d " " | tr "<" "\\n" | head -2 | tail -1 | cut -c6-)
echo "wallpaperBase64: ${getWallpaperBase64}"
getWallpaperLocation=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | grep -A 2 "relative" | head -2 | tail -1 | xargs | cut -c9- | rev | cut -c10- | rev)
echo "wallpaperLocation: ${getWallpaperLocation}"
getScreensaverBase64=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | awk '/<data>/,/<\\/data>/' | xargs | tr -d " " | tr "<" "\\n" | tail -2 | head -1 | cut -c6-)
echo "screensaverBase64: ${getScreensaverBase64}"
Step 2: From there, update lines 9 & 10 with the Base64 code that we just got, and then push out the following script in a policy:
#!/bin/bash
# Do not edit these variables.
loggedInUser=$(/usr/bin/stat -f%Su /dev/console)
wallpaper_store_path="/Users/${loggedInUser}/Library/Application Support/com.apple.wallpaper/Store"
current_RFC3339_UTC_date="$(date -u '+%FT%TZ')"
# Input the data from the 'Get Screen Saver and Wallpaper Settings' script to the variables below.
wallpaperBase64='YOUR_BASE64_CODE_HERE'
screensaverBase64='YOUR_BASE64_CODE_HERE'
# Index.plist contents.
aerial_desktop_and_screensaver_settings_plist="$(plutil -create xml1 - |
plutil -insert 'Desktop' -dictionary -o - - |
plutil -insert 'Desktop.Content' -dictionary -o - - |
plutil -insert 'Desktop.Content.Choices' -array -o - - |
plutil -insert 'Desktop.Content.Choices' -dictionary -append -o - - |
plutil -insert 'Desktop.Content.Choices.0.Configuration' -data "${wallpaperBase64}" -o - - |
plutil -insert 'Desktop.Content.Choices.0.Files' -array -o - - |
plutil -insert 'Desktop.Content.Choices.0.Provider' -string 'com.apple.wallpaper.choice.aerials' -o - - |
plutil -insert 'Desktop.Content.Shuffle' -string '$null' -o - - |
plutil -insert 'Desktop.LastSet' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Desktop.LastUse' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Idle' -dictionary -o - - |
plutil -insert 'Idle.Content' -dictionary -o - - |
plutil -insert 'Idle.Content.Choices' -array -o - - |
plutil -insert 'Idle.Content.Choices' -dictionary -append -o - - |
plutil -insert 'Idle.Content.Choices.0.Configuration' -data "${screensaverBase64}" -o - - |
plutil -insert 'Idle.Content.Choices.0.Files' -array -o - - |
plutil -insert 'Idle.Content.Choices.0.Provider' -string 'com.apple.wallpaper.choice.screen-saver' -o - - |
plutil -insert 'Idle.Content.Shuffle' -string '$null' -o - - |
plutil -insert 'Idle.LastSet' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Idle.LastUse' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Type' -string 'individual' -o - -)"
# Create the path to the screen saver/wallpaper Index.plist.
mkdir -p "${wallpaper_store_path}"
# Create the Index.plist
plutil -create binary1 - |
plutil -insert 'AllSpacesAndDisplays' -xml "${aerial_desktop_and_screensaver_settings_plist}" -o - - |
plutil -insert 'Displays' -dictionary -o - - |
plutil -insert 'Spaces' -dictionary -o - - |
plutil -insert 'SystemDefault' -xml "${aerial_desktop_and_screensaver_settings_plist}" -o "${wallpaper_store_path}/Index.plist" -
# Kill the wallpaperAgent to refresh and apply the screen saver/wallpaper settings.
killall WallpaperAgent
Make sure to also package up the images to the location that was set on the test device as well
Worked for me....setup a base device how I wanted it and ran the Pull Base64 code...got the info from the logs in Jamf and pasted it into the two fields for the code in step two and ran as policy...it tested successfully on both Apple and Intel silicon as well.
Hey All,
I have found the following scripts on the MacAdmin slack channel that seem to work.
Basically, there are two steps that need to be completed.
Step 1: Set the Screensaver on a test device manually and run the following script to pull the Base64 code of the settings:
#!/bin/bash
loggedInUser=$(/usr/bin/stat -f%Su /dev/console)
wallpaper_store_path="/Users/${loggedInUser}/Library/Application Support/com.apple.wallpaper/Store/Index.plist"
getWallpaperBase64=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | awk '/<data>/,/<\\/data>/' | xargs | tr -d " " | tr "<" "\\n" | head -2 | tail -1 | cut -c6-)
echo "wallpaperBase64: ${getWallpaperBase64}"
getWallpaperLocation=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | grep -A 2 "relative" | head -2 | tail -1 | xargs | cut -c9- | rev | cut -c10- | rev)
echo "wallpaperLocation: ${getWallpaperLocation}"
getScreensaverBase64=$(plutil -extract AllSpacesAndDisplays xml1 -o - "${wallpaper_store_path}" | awk '/<data>/,/<\\/data>/' | xargs | tr -d " " | tr "<" "\\n" | tail -2 | head -1 | cut -c6-)
echo "screensaverBase64: ${getScreensaverBase64}"
Step 2: From there, update lines 9 & 10 with the Base64 code that we just got, and then push out the following script in a policy:
#!/bin/bash
# Do not edit these variables.
loggedInUser=$(/usr/bin/stat -f%Su /dev/console)
wallpaper_store_path="/Users/${loggedInUser}/Library/Application Support/com.apple.wallpaper/Store"
current_RFC3339_UTC_date="$(date -u '+%FT%TZ')"
# Input the data from the 'Get Screen Saver and Wallpaper Settings' script to the variables below.
wallpaperBase64='YOUR_BASE64_CODE_HERE'
screensaverBase64='YOUR_BASE64_CODE_HERE'
# Index.plist contents.
aerial_desktop_and_screensaver_settings_plist="$(plutil -create xml1 - |
plutil -insert 'Desktop' -dictionary -o - - |
plutil -insert 'Desktop.Content' -dictionary -o - - |
plutil -insert 'Desktop.Content.Choices' -array -o - - |
plutil -insert 'Desktop.Content.Choices' -dictionary -append -o - - |
plutil -insert 'Desktop.Content.Choices.0.Configuration' -data "${wallpaperBase64}" -o - - |
plutil -insert 'Desktop.Content.Choices.0.Files' -array -o - - |
plutil -insert 'Desktop.Content.Choices.0.Provider' -string 'com.apple.wallpaper.choice.aerials' -o - - |
plutil -insert 'Desktop.Content.Shuffle' -string '$null' -o - - |
plutil -insert 'Desktop.LastSet' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Desktop.LastUse' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Idle' -dictionary -o - - |
plutil -insert 'Idle.Content' -dictionary -o - - |
plutil -insert 'Idle.Content.Choices' -array -o - - |
plutil -insert 'Idle.Content.Choices' -dictionary -append -o - - |
plutil -insert 'Idle.Content.Choices.0.Configuration' -data "${screensaverBase64}" -o - - |
plutil -insert 'Idle.Content.Choices.0.Files' -array -o - - |
plutil -insert 'Idle.Content.Choices.0.Provider' -string 'com.apple.wallpaper.choice.screen-saver' -o - - |
plutil -insert 'Idle.Content.Shuffle' -string '$null' -o - - |
plutil -insert 'Idle.LastSet' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Idle.LastUse' -date "${current_RFC3339_UTC_date}" -o - - |
plutil -insert 'Type' -string 'individual' -o - -)"
# Create the path to the screen saver/wallpaper Index.plist.
mkdir -p "${wallpaper_store_path}"
# Create the Index.plist
plutil -create binary1 - |
plutil -insert 'AllSpacesAndDisplays' -xml "${aerial_desktop_and_screensaver_settings_plist}" -o - - |
plutil -insert 'Displays' -dictionary -o - - |
plutil -insert 'Spaces' -dictionary -o - - |
plutil -insert 'SystemDefault' -xml "${aerial_desktop_and_screensaver_settings_plist}" -o "${wallpaper_store_path}/Index.plist" -
# Kill the wallpaperAgent to refresh and apply the screen saver/wallpaper settings.
killall WallpaperAgent
Make sure to also package up the images to the location that was set on the test device as well
For some of my test users (myself included), instead of seeing the images we placed in the screen saver assets folder, they see the colors pngs located at /System/Library/Screen Savers/Default Collections/4 - Colors. The slack thread talking about this solution mentioned it too. This doesn't happen a lot but it happens often enough to make me want to find a way to fix it. That's what I will be working on today. Out of all of the possibilities for solution for macOS Sonoma that I have explored, I think this one has the best potential to be the solution. If companies would lose their obsession with putting screen savers on everyone's computer that they won't actually sit and look at that would be the best fix!
This one has been a real butt kicker. Using the scripts found here: https://github.com/itjimbo/macOS-Screen-Saver-and-Wallpaper I created a workflow that we have been able to use to set our screen saver to some images that run as a slideshow. We distribute the new screen saver assets using a package, which deploys the images to /Library/Screen Savers/Default Collections/ScreenSaver. The scripts from itjimbo work pretty well but I noticed that there was one key piece of information that appeared to be left out of the setup process. That was the path to the screen saver assets. Oddly, just using the script called "Set Screen Saver and Keep User's Wallpaper" after running the first script to get the base64 encoded in the plist file at ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist and adding the base64 to the second script, it worked, but on some computers the screen saver would switch to just a series of colors. These colors are from the png files located at /System/Library/Screen Savers/Default Collections. It seems that macOS will just revert to this default location if it doesn't know where to look for images. I took our working script that we used with macOS Ventura and changed the path to the iLifeSlideshows component from /System/Library/Frameworks/ScreenSaver.framework/PlugIns/iLifeSlideshows.appex to /System/Library/ExtensionKit/Extensions/iLifeSlideshows.appex. The old script also had steps to write the key preferences we needed including the path to the screen saver assets. So far, the combination of the "Set Screen Saver and Keep User's Wallpaper" running first then our original script modified to work with Sonoma appears to be working. I'm sure it won't be 100% glitch free but after some tweaking, I think we may have our solution.
This one has been a real butt kicker. Using the scripts found here: https://github.com/itjimbo/macOS-Screen-Saver-and-Wallpaper I created a workflow that we have been able to use to set our screen saver to some images that run as a slideshow. We distribute the new screen saver assets using a package, which deploys the images to /Library/Screen Savers/Default Collections/ScreenSaver. The scripts from itjimbo work pretty well but I noticed that there was one key piece of information that appeared to be left out of the setup process. That was the path to the screen saver assets. Oddly, just using the script called "Set Screen Saver and Keep User's Wallpaper" after running the first script to get the base64 encoded in the plist file at ~/Library/Application Support/com.apple.wallpaper/Store/Index.plist and adding the base64 to the second script, it worked, but on some computers the screen saver would switch to just a series of colors. These colors are from the png files located at /System/Library/Screen Savers/Default Collections. It seems that macOS will just revert to this default location if it doesn't know where to look for images. I took our working script that we used with macOS Ventura and changed the path to the iLifeSlideshows component from /System/Library/Frameworks/ScreenSaver.framework/PlugIns/iLifeSlideshows.appex to /System/Library/ExtensionKit/Extensions/iLifeSlideshows.appex. The old script also had steps to write the key preferences we needed including the path to the screen saver assets. So far, the combination of the "Set Screen Saver and Keep User's Wallpaper" running first then our original script modified to work with Sonoma appears to be working. I'm sure it won't be 100% glitch free but after some tweaking, I think we may have our solution.
Here's my "step 2" script in case anyone needs it. It's a modification of the script written by the person who held my position before I started my job last year. If you have suggestions for improvement I would love to hear them! I had to make changes to the defaults write commands to work better running them as the current user.
#!/bin/bash
###########################
# Configures key user preferences for screen savers - run as step 2 to
# https://github.com/itjimbo/macOS-Screen-Saver-and-Wallpaper/blob/main/Set%20Screen%20Saver%20and%20Keep%20User's%20Wallpaper.sh
# Screen saver asset path is defined on line 31 but you could probably make this a parameter.
# 2/9/24 | Howie Isaacks
###########################
## Get current user
current_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name
&& ! /loginwindow/ { print $3 }')
current_user_id=$(/usr/bin/id -u "$current_user")
echo "Current user is "$current_user""
echo "Current user ID is "$current_user_id""
## Set key values for screen saver
echo "Setting key values for screen saver"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver CleanExit -string "YES"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver PrefsVersion -int 100
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver showClock -string "NO"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver idleTime -int 1200
## Configure screen saver framework
echo "configuring screen saver framework"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName -string "iLifeSlideshows" path -string "/System/Library/ExtensionKit/Extensions/iLifeSlideshows.appex" type -int 0
## Additional configuration settings for screen saver framework
echo "configuring screen saver settings"
sudo -u "$current_user" defaults -currentHost write com.apple.screensaver tokenRemovalAction -int 0
echo "setting asset path"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedFolderPath -string "/Library/Screen Savers/Default Collections/ScreenSaver/"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser ShufflesPhotos -bool "true"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "Classic"
## Reset
echo "relaunching prefsd..."
/usr/bin/killall -hup cfprefsd
echo "$(date) - Restarting wallpaper agent..."
killall WallpaperAgent
Here's my "step 2" script in case anyone needs it. It's a modification of the script written by the person who held my position before I started my job last year. If you have suggestions for improvement I would love to hear them! I had to make changes to the defaults write commands to work better running them as the current user.
#!/bin/bash
###########################
# Configures key user preferences for screen savers - run as step 2 to
# https://github.com/itjimbo/macOS-Screen-Saver-and-Wallpaper/blob/main/Set%20Screen%20Saver%20and%20Keep%20User's%20Wallpaper.sh
# Screen saver asset path is defined on line 31 but you could probably make this a parameter.
# 2/9/24 | Howie Isaacks
###########################
## Get current user
current_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name
&& ! /loginwindow/ { print $3 }')
current_user_id=$(/usr/bin/id -u "$current_user")
echo "Current user is "$current_user""
echo "Current user ID is "$current_user_id""
## Set key values for screen saver
echo "Setting key values for screen saver"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver CleanExit -string "YES"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver PrefsVersion -int 100
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver showClock -string "NO"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver idleTime -int 1200
## Configure screen saver framework
echo "configuring screen saver framework"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName -string "iLifeSlideshows" path -string "/System/Library/ExtensionKit/Extensions/iLifeSlideshows.appex" type -int 0
## Additional configuration settings for screen saver framework
echo "configuring screen saver settings"
sudo -u "$current_user" defaults -currentHost write com.apple.screensaver tokenRemovalAction -int 0
echo "setting asset path"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedFolderPath -string "/Library/Screen Savers/Default Collections/ScreenSaver/"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser ShufflesPhotos -bool "true"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "Classic"
## Reset
echo "relaunching prefsd..."
/usr/bin/killall -hup cfprefsd
echo "$(date) - Restarting wallpaper agent..."
killall WallpaperAgent
In the script above, I added another "killall WallpaperAgent". This is done in the first script. I added it to the second because I was noticing some behavior that I thought another relaunch would fix. If you use this script, remove or comment out that step. I don't think it's actually needed.
I have the following problem. If a user manually changed the screensaver path to the images folder, for example. /Users/user/Pictures
After running the script, this path is not changed.
How to fix the situation so that the screensaver path is accepted?
I have the following problem. If a user manually changed the screensaver path to the images folder, for example. /Users/user/Pictures
After running the script, this path is not changed.
How to fix the situation so that the screensaver path is accepted?
Which plist are you looking at? The settings are all in plists in ~/Library/Preferences/ByHost.
com.apple.ScreenSaverPhotoChooser is the plist where the path to the images would be.
On my test Mac, I went into System Settings - Screen Saver and selected my Documents folder as the folder for images. I checked the plist above and I saw that choice show up as the string for "SelectedFolderPath". I then ran my script that I posted above that contains the path we want to use for our images and it changed the string for "SelectedFolderPath" to the correct path. I used a hot corner to test the screen saver and it worked as intended. I need to know your whole process to understand why this isn't working right.
Here's my "step 2" script in case anyone needs it. It's a modification of the script written by the person who held my position before I started my job last year. If you have suggestions for improvement I would love to hear them! I had to make changes to the defaults write commands to work better running them as the current user.
#!/bin/bash
###########################
# Configures key user preferences for screen savers - run as step 2 to
# https://github.com/itjimbo/macOS-Screen-Saver-and-Wallpaper/blob/main/Set%20Screen%20Saver%20and%20Keep%20User's%20Wallpaper.sh
# Screen saver asset path is defined on line 31 but you could probably make this a parameter.
# 2/9/24 | Howie Isaacks
###########################
## Get current user
current_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | awk '/Name
&& ! /loginwindow/ { print $3 }')
current_user_id=$(/usr/bin/id -u "$current_user")
echo "Current user is "$current_user""
echo "Current user ID is "$current_user_id""
## Set key values for screen saver
echo "Setting key values for screen saver"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver CleanExit -string "YES"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver PrefsVersion -int 100
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver showClock -string "NO"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver idleTime -int 1200
## Configure screen saver framework
echo "configuring screen saver framework"
sudo -u "$current_user" /usr/bin/defaults -currentHost write com.apple.screensaver moduleDict -dict moduleName -string "iLifeSlideshows" path -string "/System/Library/ExtensionKit/Extensions/iLifeSlideshows.appex" type -int 0
## Additional configuration settings for screen saver framework
echo "configuring screen saver settings"
sudo -u "$current_user" defaults -currentHost write com.apple.screensaver tokenRemovalAction -int 0
echo "setting asset path"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedFolderPath -string "/Library/Screen Savers/Default Collections/ScreenSaver/"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaverPhotoChooser ShufflesPhotos -bool "true"
sudo -u "$current_user" defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "Classic"
## Reset
echo "relaunching prefsd..."
/usr/bin/killall -hup cfprefsd
echo "$(date) - Restarting wallpaper agent..."
killall WallpaperAgent
Thank you so much for all your work on this ! ( as well as pico and tjimbo )
Now to figure out how to reverse this -- set everything back to default
Thank you so much for all your work on this ! ( as well as pico and tjimbo )
Now to figure out how to reverse this -- set everything back to default
I'm always happy to help. I hope I can one day convince the powers that be at my company to drop using screen savers for company propaganda. The ironic thing was that one of the screen savers that they wanted pushed out was one about saving energy. We're not saving energy when we keep our displays on to show a screen saver no one looks at. Who really sits and stares at their screen when they're not working?
here is the steps to set screensaver on macOS Sonoma, I tested multiple time and moved to production its working fine.
@shrisivakumaran Should this work if the device is at the login screen.