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.

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).

  • Thanks Daniel. 1) I am totally new to this so before I start trying out your solution I'm going to try and google what ">", "<<", "eof", "/usr/bin/", "chmod", "u+x" and "./" mean and how to use them. 2) Then I will try and find out how to define a shortcut to fire a shell script. – questioner56 May 22 '16 at 23:27
  • These are shell script syntax and /usr/… are pathnames on a Unix filesystem. – daniel Azuelos May 23 '16 at 11:44

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.