MacBook – keyboard shortcut for hibernate 25 on a macbookpro retina, without changing power settings

hibernatelidmacbook propmsetsleep-wake

Question Details:

Is it possible to make your macbookpro retina (2015) to hibernate (hibernate mode 25 i.e. fully powered off) via a shortcut? I still want it to go to sleep (the usual default safesleep) when closing the lid. Put differently: I would like to achieve the same settings that I had on Windows.

Windows setting:

On my Windows (7) laptop, besides shutdown and restart, I have the option of 2 settings: sleep or hibernate. Either pressing the sleep button on my keyboard or hibernating via the start menu (by pressing the start menu, clicking the right direction button and then clicking the "Hibernate" button). Neither method requires me to close the laptop lid.

Apple Mac OS Assumption:

I am under the impression that Mac OS has the ability to hibernate just like a Windows PC – i.e. totally powered off. In order to trigger this, I must first enable this feature [sudo pmset -a hibernatemode 25] and then trigger it by closing the lid. Please correct me if I'm mistaken about this. If I'm not mistaken, please see below:

Situation:

I've just started using a Macbookpro (V10.10). I like how it goes to sleep when closing the lid. However, I would like the option to hibernate via a button/keybaord shortcut. I understand I can change the hibernate mode to hibernate 25 via pmset. However, this makes the macbook go to hibernate whenever I close the lid – I don't want it to hibernate when closing the lid, rather just hibernate via a button/shortcut.

Best Answer

This shortcut isn't defined.

You could write a small shell script:

cat >hibernate <<eof
/usr/bin/sudo pmset hibernatemode 25
pmset sleepnow
/usr/bin/sudo pmset hibernatemode 3
eof

make it executable:

chmod u+x hibernate

and test it:

./hibernate

This small shell script will ask you your password and won't echo it to get admin priviledge, and then make hibernate immediatly your Mac.

Upon wakeup, you will be able to verify that an image on disk was cleanly made with:

ls -l /var/vm/sleepimage

and you will be able to check that the hibernatemode was reset to 3, thus letting the action of closing the lid making a normal sleep.

If you are satisfied with this shell script, the next step will require to define a shortcut to fire a shell script (and this is another question).