Skip to content

Commit f29ff15

Browse files
committed
Additional changes to reduce battery drain while sleeping
1 parent 5147e77 commit f29ff15

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

setup.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,31 @@ sudo systemsetup -setsleep 60
677677
sudo systemsetup -setdisplaysleep 10
678678

679679
# Turn off feature to preserve battery life while sleeping
680+
# https://discussions.apple.com/thread/8368663
680681
sudo pmset -b tcpkeepalive 0
681682

683+
# Edit Mac-specific config to turn off tcpkeepalive and do-not-disturb while sleeping
684+
# keeps enhanced notifications from waking mac while sleeping, draining battery
685+
# Related:
686+
# https://forums.macrumors.com/threads/psa-if-your-2015-or-2016-mbp-has-some-battery-drain-while-sleeping-here-is-the-fix.2026702/
687+
# https://apple.stackexchange.com/questions/253776/macbook-pro-13-with-retina-display-consumes-10-battery-overnight-with-the-lid-c
688+
# https://support.apple.com/en-us/HT201960
689+
csrutil status | grep enabled > /dev/null
690+
if [ $? -eq 0 ]
691+
then
692+
echo "Cannot disable tcpkeepalive properly"
693+
echo "Please reboot and hold command-r to start the recovery tool"
694+
echo "When it loads, open the terminal and type `csrutil disable` and then reboot and try again"
695+
echo "When finished, reboot into the recovery tool, and enter 'csrutil enable' in the terminal again"
696+
else
697+
MODEL=`ioreg -l | awk '/board-id/{print $4}' | sed 's/[<">]//g'`
698+
echo "Altering configuration for model $MODEL"
699+
echo "Disable network wake when sleeping"
700+
sudo /usr/libexec/PlistBuddy -c "Set :IOPlatformPowerProfile:TCPKeepAliveDuringSleep false" /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources/$MODEL.plist
701+
echo "Enable Do Not Disturb while display is asleep"
702+
sudo /usr/libexec/PlistBuddy -c "Set :IOPlatformPowerProfile:DNDWhileDisplaySleeps true" /System/Library/Extensions/IOPlatformPluginFamily.kext/Contents/PlugIns/X86PlatformPlugin.kext/Contents/Resources/$MODEL.plist
703+
fi
704+
682705
#############################################
683706
### Install dotfiles repo
684707
#############################################

0 commit comments

Comments
 (0)