os_sleep_and_display_sleep_apple_silicon_enable Ensure Sleep and Display Sleep Is Enabled on Apple Silicon Devices
All changes in this version
Title
Ensure Sleep and Display Sleep Is Enabled on Apple Silicon Devices
Control
error_count=0
if /usr/sbin/system_profiler SPHardwareDataType 2>/dev/null | /usr/bin/grep -Ei "MacBook|Mac[0-9]" > /dev/null ; then
cpuType=$(/usr/sbin/sysctl -n machdep.cpu.brand_string)
if echo "$cpuType" | grep -q "Apple"; then
sleepMode=$(/usr/bin/pmset -b -g | /usr/bin/grep '^\s*sleep' 2>&1 | /usr/bin/awk '{print $2}')
displaysleepMode=$(/usr/bin/pmset -b -g | /usr/bin/grep displaysleep 2>&1 | /usr/bin/awk '{print $2}')
if [[ "$sleepMode" == "" ]] || [[ "$sleepMode" -gt 15 ]]; then
((error_count++))
fi
if [[ "$displaysleepMode" == "" ]] || [[ "$displaysleepMode" -gt 10 ]] || [[ "$displaysleepMode" -gt "$sleepMode" ]]; then
((error_count++))
fi
fi
fi
echo "$error_count"
Discussion
Apple Silicon MacBooks should set sleep timeout to 15 minutes (900 seconds) or less and the display sleep timeout should be 10 minutes (600 seconds) or less but less than the sleep setting.
Fix
[source,bash]
----
/usr/bin/pmset -a sleep 15
/usr/bin/pmset -a displaysleep 10
----