Screensaver Password Status

I had been using a pre-existing extension attribute to check if a user's preferences were set to require a password after a screensaver started. This is important for us, as we use screensaver preferences as a way to "lock" the Mac screen, much like our Windows users can hit Windows+L to lock their screen.



I had been using a pre-existing extension attribute to check if a user's preferences were set to require a password after a screensaver started. This is important for us, as we use screensaver preferences as a way to "lock" the Mac screen, much like our Windows users can hit Windows+L to lock their screen.

The previously existing extension attribute required a managed preference (MCX) to check the settings. I came up with a script that would pull the current user and put it into the exact path to the com.apple.screensaver file that stores the preference.


ScreenSaverPasswordRequired.sh

#!/bin/bash

#
# script by emily k @ volusion 2014-06-10
# check for user’s screensaver login screen preferences
#

currentUser=`ls -l /dev/console | cut -d " " -f 4`

status=`defaults read "/Users/$currentUser/Library/Preferences/com.apple.screensaver.plist" askForPassword`

if [ "$status" == "0" ]; then
    result="False"
elif [ "$status" == "1" ]; then
    result="True"
else
    result="Not set."
fi    

echo "<result>$result</result>"


Include this as an extension attribute script that shows up in your computer inventory. You can even create a smart group that checks for True, False, or Not Set and then scope a policy to the machine to adjust the setting. Magic.


Write a comment