Posted on 12-17-2019 05:07 AM
Anyone able to set screensavers on Catalina. I had below script that worked fine for Mojave - but for Catalina it does not
#!/bin/sh
# Get user logged into console and put into variable "user"
user=`ls -l /dev/console | cut -d " " -f 4`
osMajor=$(sw_vers -productVersion | awk -F"." '{print $2}')
osMinor=$(sw_vers -productVersion | awk -F"." '{print $3}')
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"
sudo -u $user defaults -currentHost write com.apple.screensaver idleTime -int 120
if [[ $osMajor -eq 14 ]] && [[ $osMinor -ge 2 ]]; then
sudo -u $user 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
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
fi
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/EC/lockscreens"
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
sudo -u $user defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "Classic"
sudo killall -hup cfprefsd
Posted on 01-27-2020 01:06 PM
Try this instead - note that I changed the actual screen saver and the photo path being applied to suit my uses...
#!/bin/zsh
# Get user logged into console and put into variable "user"
user=`ls -l /dev/console | cut -d " " -f 4`
osMajor=$(sw_vers -productVersion | awk -F"." '{print $2}')
osMinor=$(sw_vers -productVersion | awk -F"." '{print $3}')
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"
sudo -u $user defaults -currentHost write com.apple.screensaver idleTime -int 120
if [[ $osMajor -eq 14 && $osMinor -ge 2 ]] || [[ $osMajor -ge 15 ]] ; then
sudo -u $user 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
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
fi
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/Screen Savers/Default Collections/MyPics"
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser SelectedSource -int 3
sudo -u $user defaults -currentHost write com.apple.ScreenSaver.iLifeSlideShows styleKey -string "VintagePrints"
killall -hup cfprefsd
The issue in the old script was that the "if" statement was looking for anything that was a major OS version equal to 14, and had a minor OS version greater than or equal to 1. But that meant that under catalina it didn't meet the major OS version so it applied the 10.14.1 and earlier fix.
Posted on 04-14-2020 12:51 PM
@JCMBowman Thank you, this worked nicely!
Does anyone know what I would have to change in order to uncheck Shuffle Slide Order off?
Thanks!
Posted on 04-14-2020 01:46 PM
@Lives - try adding this line near the similar lines for com.apple.ScreenSaverPhotoChooser:
sudo -u $user defaults -currentHost write com.apple.ScreenSaverPhotoChooser ShufflesPhotos -bool FALSE
Posted on 12-14-2020 02:02 PM
I tried using this script and it does not seem to work for me at all on any MacOS version. No matter what I do, it only shows the stock photos. I verified the folder path is correct. Is there something else that needs to be changed aside from the SelectedFolderPath? Hopefully I'm just missing something small!
Posted on 12-15-2020 07:12 AM
I'm using this to set custom screensavers across all our Mac (macOS 10.13.x - 10.15.7 ) and it works great. I have custom folder created at "/Library/Screen Savers/Default Collections/CompanyName" where I place the image files and then execute the script (postinstall)...
#!/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 1200
## 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 "/Library/Screen Savers/Default Collections/CompanyName/"
/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
Posted on 12-15-2020 10:05 AM
This worked well for me. Thank you stranger!
Posted on 03-18-2021 03:27 AM
Hi @smpotter,
Thank you very much for this script. It is also working on an M1 MacBook and Big Sur!
BR
Daniel
Posted on 08-06-2021 05:51 AM
Does anyone know the variables for the -stylekey string? im looking for Vintage Prints but can't figure it out...
Posted on 06-11-2022 09:12 AM
is it still working? tested in Catalina and Monterey its not working, screensaver is not working with custom image. does anyone have working scripts or policy?
Posted on 11-27-2023 09:49 AM
@smpotter this script is not working on Sonoma.
Do we need to modify it for Sonoma OS?