Hibernate with the MacBook Pro

Thanks to Dion for pointing out how to get your MacBook to hibernate! When I wrote about switching to the MacBook Pro one of my complaints was that upon shutting the lid the laptop doesn’t hibernate, it sleeps, and they offer you no easy way to switch it via the GUI.

I don’t mind waiting a for my laptop to start when I open the lid and the little white sleeping light drives me nuts, especially if I forget and leave it in our bedroom before going to bed. That sucker lights up the room at night!

So I added the two aliases that Dion suggest, sourced my bashrc, ran hibernateon, shut the lid, and off goes the light… amen!

alias hibernateon='sudo pmset -a hibernatemode 1'
alias hibernateoff='sudo pmset -a hibernatemode 0'
This entry was posted in Desktop, OSX. Bookmark the permalink.

9 Responses to Hibernate with the MacBook Pro

  1. Dion Almaer says:

    Hi Todd,

    Glad it was useful. Enjoying the MBP?

    Dion

  2. Chuck Cheeze says:

    Hi Todd, not so new to MBP anymore but still learning bash stuff. Would you consider doing a step by step? For instance, what does “added two aliases” mean? How do I do that and where? Same with “sourced my bashrc” and “ran hibernateon”. Just a little help for a noob.

  3. dalesan says:

    Thanks for the great tip. My MBP has a bad tendency to wake up while in my backpack. This morning I could’ve fried an egg on it. This hibernation tip should do nicely.. Thanks!

  4. Jinesh Udani says:

    This is a brilliant tip. I have been using Windows all these years and always used to Hibernate my laptop since it helps me to start my laptop quickly. Ever since I moved to a MBP, I was missing this feature, Thanks a lot.

  5. Mark Wheadon says:

    Or for those who only sometimes want the machine to hibernate — how about a more hands-on approach:

    http://www.markwheadon.com/blog/2009/01/hibernate-macbook/

    Marjk

  6. Philipp says:

    I wrote myself the following little script (just copy/paste into a text file)

    #!/bin/bash

    case “$1″ in
    default)
    sudo pmset -a hibernatemode 3
    ;;
    hibernate)
    sudo pmset -a hibernatemode 1
    ;;
    sleep)
    sudo pmset -a hibernatemode 3
    esac

    mode=`pmset -g | grep hibernatemode | sed -e ‘s/[^0123456789]*//g’`
    case “$mode” in
    1)
    echo “hibernate”
    ;;
    3)
    echo “sleep”
    ;;
    *)
    echo $mode
    esac

    I named it /usr/bin/lidmode
    after saving i executed the following in Terminal

    sudo chown root:admin /usr/bin/lidmode
    sudo chmod 04755 /usr/bin/lidmode

    now if I go into Terminal and execute
    lidmode
    it tells me which mode is currently on
    and by doing
    lidmode sleep
    or lidmode hibernate
    I can set the mode I want for the lid.

    I then wrote a second script I call /usr/bin/slumber

    #!/bin/bash

    HM=`pmset -g | grep hibernatemode | sed -e ‘s/[^0123456789]*//g’`

    case “$1″ in
    deeply)
    mode=1
    ;;
    lightly)
    mode=3
    ;;
    *)
    mode=$HM
    esac

    sudo pmset -a hibernatemode $mode
    osascript -e “tell application \”finder\”" -e “sleep” -e “end tell”
    sudo pmset -a hibernatemode $HM

    I also executed
    sudo chown root:admin /usr/bin/slumber
    and
    sudo chmod 04755 /usr/bin/slumber

    Than enables me to just execute
    slumber lightly
    if I want the mb to go to sleep or
    slumber deeply
    if I want the mb to hibernate immediately

    I hope these make things a bit more comfy.

    For those that like Icons ;) you could just create those scripts and then use Automator to create Actions that can be called via clicking on an Icon. But that is for another story.

    Greetings, Phil

  7. Ulisses Braga-Neto says:

    This worked very well, many thanks. I was tired of my MBP waking up inside my bag. Your choice of names is great. I made a small modification to make them a tad shorter: “sleep light” and “sleep tight”.

  8. Axonic Labs says:

    There is a DeepSleep Widget that will hibernate your Mac or MacBook with one click and it maintains regular sleep when you shut the lid. Check it out http://www.axoniclabs.com/DeepSleep/

  9. DataGreed says:

    This deep sleep widget doesn’t work

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>