Thursday, February 21, 2008

MacBookPro Faster Sleep

When I close the lid on my MacBookPro the white light stays on for 20-30 seconds... and then starts pulsing. It is taking this time to write the RAM contents to the HD in case the battery runs down or is removed this allows the computer to wake up and resume where I left off. There are a couple of command line options that one can enter to turn this on and off. Per this hint you can also save a shell script to make this process easier. I've included the script text here:



if [ "$SETTING" == "off" ]; then
echo "Turning off safe sleep"
sudo pmset -a hibernatemode 0
sudo nvram "use-nvramrc?"=false
echo "Don't forget to reboot!"
echo You are now free to remove your sleepimage file at /private/var/vm/sleepimage
elif [ "$SETTING" == "on" ]; then
echo "Turning on safe sleep"
sudo pmset -a hibernatemode 3
sudo nvram "use-nvramrc?"=true
echo "Don't forget to reboot!"
echo "Usage: safesleep on | off"

I put this in a file named safesleep in this directory: ~/Scripts/shell/. ~ is a shortcut for the current user's home directory. Then I made the file executable by running chmod on it:

sudo chmod ug+x ~/Scripts/shell/safesleep

I also had to add the ~/Scripts/shell directory to my path, so I created a new file at ~/.profile, into which I put:

export PATH="/bin:/sbin:/usr/bin:/usr/sbin:~/Scripts/shell"

Restart the shell (quit Terminal) and the script is ready to rock. Syntax is either "safesleep on" or "safesleep off". The script will remind you to reboot the computer for it to take effect.

I also installed the Dashboard widget Deep Sleep. This fellow causes the laptop to directly enter deep sleep. Deep sleep is a state that uses no power, the white light does not pulse, it is completely off. You do have to wait the 20-30 seconds for the ram to be written to the hard drive.

The combination of a safesleep off for fast normal sleeping, and Deep Sleep for no battery long term sleeping works well for me.

No comments:

Favorites from my Blogroll