Thanks for the script. I was able to run with Jamf and it did exactly what you indicated!
Here's what I do for this, in case it helps anyone else... ( our screen lock policy)
- Password required instantly after screen wake, screen saver, sleep (via Security & Privacy profile)
- Screen Saver set to a hard 20min - this is the only real way to force the machine to lock consistently (must be Apples preset time options)
- Power Management set to sleep the Displays at 20 mins via a script. Now, since the user can always change this on their own and I dont want to enforce the other options in power management, and even with a profile the display sleep time is user adjustable, we do it with with a script, a EA and a smart group.
3a. EA to find all machine with a current display sleep time over 20min (power or battery)
3b. Smart Group to collect machines with values over 20mins
3c. Policy to run a script to set the display sleep accordingly.
So, if a user sets a time over 20mins, Jamf sets it back to 20/5 (power/battery) at some point, they can run higher for a while but useally in 1 day it kicks back. This lets them change it anywhere from 0-20, but if they go over Jamf will eventually catch them. Yes the stubborn user can avoid this changing it daily, but they cant avoid the 20min screen saver. So really its just a power saving thing. Keeps the screens off as much as possible.
Heres our EA
#!/bin/sh
echo "<result>`/usr/bin/pmset -g 2>&1 | grep displaysleep | awk '{print $2}'`</result>"
Heres our Display Sleep (use parameters for the values)
#!/bin/bash
#set Display sleep Battery
pmset -b displaysleep $4
#set Display sleep power Adapter
pmset -c displaysleep $5
#set Display sleep ups
pmset -u displaysleep $6
Not sure if this is KISS or not with all the layers, but we try...
I have scheduled to make all iMacs at my office come on at 6am in the mornings on weekdays (and going off at 7pm). I don't really want to mess up this schedule, but I want a one-time exception to have them NOT come on on a specific day (Bank Holiday). Any suggestions?
@ScottSimmons Re: #3. I was recently playing around with a configuration profile to control display sleep on portables and while it's true that a user can go in after the fact and change the value set in the config profile, it doesn't stay for long. There is a time frame where the config profile is enforced and the value changes back. Sounds like what you're doing manually with the script. FYI.
@ScottSimmons thanks for your post! It was very helpful. Your EA displays whichever sleep setting is currently active so will vary based on if User is on battery or power adaptor when inventory is run. I set up this EA to display of whichever one is greater.
#!/bin/bash
## sleep time EA
displaySleepBatt=`pmset -g custom | awk '/Battery Power/{f=1} /disksleep/{f=0;print} f' | grep "displaysleep" | awk '{print $2'}`
displaySleepPower=`pmset -g custom | awk '/AC Power/{f=1} /disksleep/{f=0;print} f' | grep "displaysleep" | awk '{print $2'}`
## determine if battery or power adaptor setting is greater
if (( $displaySleepBatt > $displaySleepPower )) ; then
greater=$displaySleepBatt
else
greater=$displaySleepPower
fi
echo "<result>$greater</result>"
exit 0