A Guide for Custom Screen Savers

clegger06
New Contributor III

There is a lot of information about custom macOS screen savers and how to implement, but it took me a long time to sort through everything and find answers, so i am posting my findings here. I am going to try to keep it simple.

Task: Deploy a custom screen saver built by an in house developer using xcode in .saver format. Set the screen saver for the login window and the logged in user.

Solution:
Part 1 - According to an Apple KB article, you cannot set a "Custom" screen saver at the login window. The article publish date is a bit stale, but after working with Jamf Support and my own testing, this still holds true up to macOS 10.15.2 (also tested on macOS 10.14.6). https://support.apple.com/en-us/HT202223

Part 2 - You can however set a screen saver for a logged in user. Package up your custom screen saver, install it at the /Library/Screen Savers/ path. Add the script below to Jamf Pro. This script was provided to me by Jamf Support.

Create a policy, set it for check-in once per computer (or ongoing as outlined in Step 3, keep reading), add the .dmg, add the script and scope it. See Part 3 for scoping instructions

 #!/bin/bash

# VARIABLES
screenSaverModuleName="Screen_Saver_Name"
screenSaverFileName="Screen_Saver_Name.saver"
screenSaverPath="/Library/Screen Savers"

# DO NOT EDIT BELOW THIS LINE
user=$(last | grep "logged in" | grep "console" | awk '{print $1}');
huuid=$(system_profiler SPHardwareDataType | awk '/Hardware UUID/ {print $3}')

/usr/libexec/PlistBuddy -c "Set moduleDict:moduleName $screenSaverModuleName" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist
/usr/libexec/PlistBuddy -c "Set moduleDict:path $screenSaverPath/$screenSaverFileName" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist

setName=$(/usr/libexec/PlistBuddy -c "Print moduleDict:moduleName" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist)
setFile=$(/usr/libexec/PlistBuddy -c "Print moduleDict:path" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist)

killall cfprefsd

Part 3 - If you don't need to force the saver, you can simply scope this to All Devices or however you see fit.

If you do need to force this, you have 2 options. The first option is to use a Config Profile with Restrictions and lock down the "Desktop and Screen Saver" Sys Pref Pane. Once deployed, then scope the policy above to all devices. Do note, this will prevent the user from also setting a custom Desktop image. Most Admins will find, this is not a viable option.

The second option is what i chose, create an Extension Attribute which confirms the file is present on the device. Scope the policy above using a Smart Computer Group to anyone who does not have the file. Set this policy to run ongoing at check-in. Now anyone who deletes or renames the file will have it redeployed automagically. LastIy, I created a second policy. This second policy simply runs the script once per day at check-in, this will continually set the screen saver for anyone who might change it.

Final Thoughts - I hope this helps someone save time.

5 REPLIES 5

mzalmai
New Contributor II

I tried using the script provided. The script runs successfully but then it removes the user's access from com.apple.screensaver.$huuid.plist file. Only does system will have access to the file and screensaver won't work

Geant-IT
New Contributor

Part 2 I can't seem to figure out, how can I package a custom screen saver?

MikeyJAP
New Contributor II

I'll be using Fliqlo.saver as an example. 

1. On your Jamf Workstation, place the screensaver you plan on deploying under /Library/Screen Savers/

MikeyJAP_0-1647624267399.png

2. Drag and drop the Fliqlo.saver from /Library/Screen Savers/ inside of Jamf Composer.

MikeyJAP_1-1647624398435.png

3. Click Build PKG or Build DMG. I prefer PKG to check receipts to confirm which machines has it installed locally or via Jamf Pro.

MikeyJAP_2-1647624468368.png

4. Upload the Script to your Jamf Pro instance via Settings > Computer Management > Scripts.

5. Create a Policy and make sure to add your PKG and your script to run after the PKG has been installed.

 

Quick note*

I modified the script to install the screensaver for all users on a local machine since the script provided only installs for the last user that logged in which will be a bummer if you work in a school environment where multiple macOS devices are used by multitple students, and accounts cleaned up every once in a while.

 

 

 

#!/bin/bash

# VARIABLES
screenSaverModuleName="Fliqlo"
screenSaverFileName="Fliqlo.saver"
screenSaverPath="/Library/Screen Savers"

# DO NOT EDIT BELOW THIS LINE
localUsers=$( dscl . list /Users UniqueID | awk '$2 >= 501 {print $1}')
huuid=$(system_profiler SPHardwareDataType | awk '/Hardware UUID/ {print $3}')

for user in $localUsers; do
    /usr/libexec/PlistBuddy -c "Set moduleDict:moduleName $screenSaverModuleName" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist
    /usr/libexec/PlistBuddy -c "Set moduleDict:path $screenSaverPath/$screenSaverFileName" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist

    setName=$(/usr/libexec/PlistBuddy -c "Print moduleDict:moduleName" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist)
    setFile=$(/usr/libexec/PlistBuddy -c "Print moduleDict:path" /Users/$user/Library/Preferences/ByHost/com.apple.screensaver.$huuid.plist)
 
done


killall cfprefsd

 

 

 

 

Thanks for putting in a loop to catpure all users, however ive noticed that previously the script worked ok but plistbuddy seems to fail now if not already present, getting lots of these errors:-

File Doesn't Exist, Will Create: /Users//Library/Preferences/ByHost/com.apple.screensaver.F8434417-2890-5233-84F4-2E3F5508338E.plist

Set: Entry, "moduleDict:moduleName", Does Not Exist


anyone else come across this in later versions of Monterey? maybe it needs to be detected and then changed to Add?

 

thomastsang
New Contributor II

How about use "Classic" slideshow screen saver module?