Skip to main content

MAC Screen Lock Timer

Summary

This agent procedure is used to modify the default Mac screensaver timing as well as the time for the display to turn off.

Example Agent Procedure Log

TimeProcedureStatusUser
11:05:46 am 2-Feb-23MAC Screen Lock TimerSuccess THENprovaltech.com/derek.joniak
11:05:46 am 2-Feb-23MAC Screen Lock TimerDisplay sleep modified to 10 minutes.provaltech.com/derek.joniak
11:05:46 am 2-Feb-23Execute Shell command - Get Results to VariableSuccess THENprovaltech.com/derek.joniak
11:05:46 am 2-Feb-23Execute Shell command - Get Results to Variable-0007Executing command in standard shell as system: pmset -a displaysleep 10 >"/Library/Kaseya/provaltech/commandresults-1279138153.txt" 2>&1provaltech.com/derek.joniak
11:05:42 am 2-Feb-23MAC Screen Lock TimerScreensaver modified to 300 seconds.provaltech.com/derek.joniak
11:05:42 am 2-Feb-23Execute Shell command - Get Results to VariableSuccess THENprovaltech.com/derek.joniak
11:05:42 am 2-Feb-23Execute Shell command - Get Results to Variable-0007Executing command in standard shell as system: defaults write /Library/Preferences/com.apple.screensaver.plist idleTime -int 300 >"/Library/Kaseya/provaltech/commandresults-767522558.txt" 2>&1provaltech.com/derek.joniak
11:05:31 am 2-Feb-23Run Now - MAC Screen Lock TimerAdmin provaltech.com/derek.joniak scheduled procedure Run Now - MAC Screen Lock Timer to run at Feb 2 2023 12:05 PMprovaltech.com/derek.joniak

Variables

NameDescription
screensaverModifies the time until the screensaver activates (Value is in seconds)
displayModifies the time until the display turns off (Value is in minutes)

Process

The agent procedure modifies two settings on the Mac machine via executeShellCommandToVariable.

  • Modifies the default .plist file for the screensaver:

    • defaults write /Library/Preferences/com.apple.screensaver.plist idleTime -int #screensaver#
  • Modifies the pmset setting for the display:

    • pmset -a displaysleep #display#

Note: While the pmset command actively updates the GUI to reflect the setting (number 2 in the image), modifying the .plist does not update the GUI (number 1 in the image). The setting takes effect actively but does not have its GUI updated to reflect the change. The pmset command cannot change the screensaver, so the .plist file is modified to achieve this.

Image