screensaver script, random login-window prompt

walt
Contributor III

Using the below script to call a custom screen saver works, but with the following glitch and I'm not sure where to troubleshoot.

Screensaver is set to launch at 5 minutes of inactivity, which it does. however after 5 minutes of the screensaver running it prompts the log-in window, then 20 seconds after that, the display sleeps.

However, using the same script on $OTHER_MDM for Macs, screensaver starts after 5 minutes and does not prompt the log-in window, it runs until the display sleep (set for at 10 minutes).

Both test Macs:
10.15.3
screensaver starts at 5 min
display sleep set to 10 min

#!/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 300


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 "/usr/local/corpscreensaver/"
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"

killall -hup cfprefsd
3 REPLIES 3

walt
Contributor III

would anyone know what could be the issue? or able to replicate? are there suppose to be values in Jamf somewhere for $2 and $3?

for the other MDM we use, the screensaver folder is packaged in composer with a post-install script using the above script. so that one works completely fine. (5 minutes SS starts, then after 10 minutes display sleeps) in Jamf it stops after 5 minutes and returns to the login window.

thanks

shaquir
Contributor III

Hi @walt ,

Can you please confirm what value is set in Require password to wake this computer from sleep or screen saver

a85354878e59467cb55dd1b495d3c2fa

I did not notice anywhere in the script where the log-in window is modified (I'd be expecting a "askForPassword" or "askForPasswordDelay" value). I would also check to see if your MDM has a Config Profile set for this value. In Jamf it may be found:

b16c41526520487197a8906c29a7f065

You could also check the plist values within com.apple.screensaver.plist. You can also confirm System-wide power settings by using:

pmset -g

If you are still banging your head on the wall, you can try configuring these settings by using ProfileCreator. There is a ScreenSaver payload that you should be able to use:

5170cad69d0448dba28d8c73abf1c2bb

Finally, the $2 and $3 values that you are referring to are not to be confused with the Jamf Script Parameters.

When $2 is placed in an awk (filtering command) like:

awk '{print $2}'

it simply outputs the second line of the pipped result.

walt
Contributor III

Hi @shaquir, the only profile for that is set to immediately require password after screensaver and that usually prompts the username/password over the screensaver rather than log-in window. We don't have an energy setting profile, but the screen sleep is set for 10 minutes.

thanks