PDA

View Full Version : Force hibernate, but default to sleep




Supp0rtLinux
Mar 4, 2013, 09:10 AM
I've done some searching before posting this, but I'm not finding the answer I'm looking for. I want to be able to do a "one-time hibernate", perhaps through a shell script, maybe via an Automator action, etc but I still want my MBP to "sleep" by default. It seems all the answers to the searches I've tried want me to use pmset to globally change the option from defaulting to sleep to defaulting to hibernate.

Here's my scenario: during the week, sleep is fine for me. However, when I leave on Fridays if I put my laptop to "sleep", then by Sunday afternoon its at about 15-20%. So what I want is to tell it to "hibernate" when I leave on Friday evening so that if I pull my laptop out on Sunday afternoon it has closer to 80-90% of the battery. So I want it to default to "sleep" if I close the lid, but I want a script, shortcut, etc to be able to force it to hibernate. An even better option would be to have it sleep on lid close, but to have the "sleep" option under the Apple menu to say hibernate instead of sleep and to be able to just click that to force it to hibernate. Any thoughts or suggestions?



estutmirleid
Mar 4, 2013, 09:47 AM
So what I want is to tell it to "hibernate" when I leave on Friday evening so that if I pull my laptop out on Sunday afternoon it has closer to 80-90% of the battery.
I don't think that's how Hibernate functions. It still Sleeps as normal, and thus uses battery as normal, but when the battery runs out there's the sleepimage created by Hibernate to recover from.

I'd confirm your hypothesis is correct before pursuing this further, because I'm pretty confident I'm right, based on experience of my own MBP.

GGJstudios
Mar 4, 2013, 09:50 AM
So what I want is to tell it to "hibernate" when I leave on Friday evening
If the Mac you're referring to is not a retina MBP or MBA, hibernation (aka "deep sleep" or "standby mode") is not an option, as it's not available on other models.

Mac notebooks: About standby mode (http://support.apple.com/kb/HT4392)

estutmirleid
Mar 4, 2013, 10:11 AM
If the Mac you're referring to is not a retina MBP or MBA, hibernation (aka "deep sleep" or "standby mode") is not an option, as it's not available on other models.

Mac notebooks: About standby mode (http://support.apple.com/kb/HT4392)

That's a different feature that allows a certain amount of activity such as Mail downloading etc. when the notebook is in "sleep" and is, indeed, only available on certain models.

GGJstudios
Mar 4, 2013, 10:26 AM
That's a different feature that allows a certain amount of activity such as Mail downloading etc. when the notebook is in "sleep" and is, indeed, only available on certain models.
You're thinking of Power Nap, which also is only available on MBA and rMBP models. Neither Power Nap nor Standby Mode is available on other Mac models.

Mountain Lion: About Power Nap (http://support.apple.com/kb/ht5394)

Supp0rtLinux
Mar 4, 2013, 10:30 AM
I have a late 2011 MBP… the last of the 15'' MBP's before the rMBP's. Sleep and hibernate are both options. Sleep will have it run on reduced power, but provide power to the memory. When power runs out, it will go to hibernate (deep sleep) where in memory contents are written to the hard disk. I can use pmset option to force it to always deep sleep instead of "regular sleep". But from what I'm seeing, if I use pmset to change the sleep options, its an always thing. In other words… if I use pmset to change the behavior then anytime I close the lid it will deep sleep. I want it to do "normal sleep" anytime I close the lid, but be able to force it to do hibernate (deep sleep) manually.

GGJstudios
Mar 4, 2013, 10:35 AM
I have a late 2011 MBP… the last of the 15'' MBP's before the rMBP's. Sleep and hibernate are both options. Sleep will have it run on reduced power, but provide power to the memory. When power runs out, it will go to hibernate (deep sleep) where in memory contents are written to the hard disk.
I see what you're saying now. It's a bit confusing, as the terms "hibernate" and "deep sleep" are frequently used to refer to Standby Mode.
I can use pmset option to force it to always deep sleep instead of "regular sleep". But from what I'm seeing, if I use pmset to change the sleep options, its an always thing. In other words… if I use pmset to change the behavior then anytime I close the lid it will deep sleep. I want it to do "normal sleep" anytime I close the lid, but be able to force it to do hibernate (deep sleep) manually.
I'm not aware of any method of achieving what you're trying to accomplish.

estutmirleid
Mar 4, 2013, 11:00 AM
Ok, just to clarify, there are various sleep settings available on Macs. From pmset:

hibernatemode = 0 (binary 0000) by default on supported desktops. The
system will not back memory up to persistent storage. The system must
wake from the contents of memory; the system will lose context on power
loss. This is, historically, plain old sleep.

hibernatemode = 3 (binary 0011) by default on supported portables. The
system will store a copy of memory to persistent storage (the disk), and
will power memory during sleep. The system will wake from memory, unless
a power loss forces it to restore from disk image.

hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The
system will store a copy of memory to persistent storage (the disk), and
will remove power to memory. The system will restore from disk image. If
you want "hibernation" - slower sleeps, slower wakes, and better battery
life, you should use this setting.
(emphases mine)

Let me also quote the manual once more:
For your sake and mine, please don't use anything other 0, 3, or 25.

At the very least you now know more precisely what you need, ie. setting "25".

Personally, I think whatever you do it'll involve making a global change via pmset that is then undone for Monday when you go back to work.

Supp0rtLinux
Mar 4, 2013, 11:55 AM
Yeah… I'm thinking about a Applescript/shell script called by Automator that sets it to 3 on Monday morning and to 25 on Friday afternoon… perhaps in conjunction with cron or launchd instead of Automator. That part is sort of easy to sort out… I was just hoping for a "default to 3 all the time" but "manually do a 25". Put differently, closing the lid of choosing Apple > Sleep would have it sleep (3) but clicking on my custom script from Applications would have it immediately hibernate (25).