Since quite some time Mac OS also has a hibernation mode, also known as suspend-to-disk. But as usual for Mac, you cannot select it by hand. In fact, a suspend-to-ram always does a suspend-to-disk as well, so that in a case of power loss (like empty battery) you can start the computer from the image on the hard disk without losing anything. Apple calls this suspend combination “Safe-Sleep“.
So far so nice. But sometimes you might want to go directly into hibernation mode. Therefore I wrote a little applescript, which in respect to similar scripts doesn’t need any administrator rights to work. In fact the icon was the most difficult part.
Download it right here.
For an easy access to the hibernation mode, you either move it to /Applications/ or somewhere else and drag it into your dock, or you put it in ~/Library/Scripts and activate the script menu with the Applescript Utility.
PS.: If your Mac does not support the hibernation mode, there is a chance that you can enable it. Look here.
PPS.: As a Mac OS X user you might also be interested in another tool by me: UpdateCheckΒ (Software Update Notifications for Non-Admin-Users)
Troubleshooting:Β if you experience that your computer still goes into normal sleep mode, open Hibernate.app/Contents/Resources/Scripts/main.scpt and increase the delay to 30 at the end of the script.
Pingback: Ralf's Blog
Exactly what i needed, great work π
As i’m used to have the Dashboard turned off for performance improvements i needed the “Deep Sleep”-Widget as App-Solution – got it π
Thank you – this is exactly what I have been looking for. There are a couple of apps out there that are far too clever, all I’ve wanted was something that would let me hibernate the computer at the end of the day without interfering with the MacBook’s usual sleep mode which is really quick and effective. This is perfect. Many thanks.
this is great–please continue to update it. i think hibernation is more energy efficient, and thus much better for the environment, than normal sleep. (perhaps apple likes selling batteries more than saving the world?) i would love the option to turn off the confirmation dialog, however, to make it quicker. it’s just an extra step i don’t need, since the worst result of a mistaken double-click is 30 lost seconds. danke!
@matt: you can easily change that on your own. Just open Hibernate.app with the “Script Editor.app” and add a
--
to the beginning of the linedisplay dialog ("Do you want to hibernate?" &...
Hello,
thank you for sharing this very useful app. I think though, that it doesn’t save the ram where the safe sleep saves it, but on a different location instead. Since I got 4 gigs of ram, safe sleep takes 4 gigs, and I think now that I ran hibernate.app it takes another 4 gigs.
If I’m right, may I ask where it saves them so I can delete them manually?
Thanks
@Orestis: The tool doesn’t decide were to save the memory. It just tells the system to go into hibernation. Everything else is done by Mac OS, so I have no idea why there should be a difference. And to be honest, I don’t believe it, you are probably seeing something else.
Is it possible to write a script for the hibernatemode 5 instead of 1? Thanks.
@Tom: The man page of pmset doesn’t say anything about hibernatemode 5, so I have no idea what that mode is. But if you know, what you do, you can just drag the Hibernation.app on the Script Editor and change the value in line
do shell script "/usr/bin/pmset force -a hibernatemode 1"
Thanks, that worked great. Mode 5 is the same as 1 except for use with secure memory setting on newer macs.
From a macworld article:
@Tom: I think this information is not accurate. I remember modes 5 and 7 were mentioned in older man pages of pmset, but Apple removed it with a reason I assume. Just read section “A Question of Encryption” in this article: http://db.tidbits.com/article/9115
I quote: “Don’t ever use 5 or 7.”
Pingback: the switch, extended » scribbling damselfly » deborahkalin.com
This works great! Thank you for this
Pingback: How to enable hibernate mode on a Mac | Geek Guides
Pingback: kaputtendorf » UpdateCheck
Sometimes when resuming from Hibernation, the mouse cursor is still set to the wait wheel (black / white)?
Thanks very much for this app; it works very well. However, I was wondering: I’d like to use this as a way to more quickly switch between Windows and Mac OS X. When I turned the machine back on, I held down the Option key but was not presented with a choice of OSes to load — it just went straight back into OS X.
Do you know of any way to work around this so that I can chose to run Windows instead? I’m aware of Virtual Machines and the like but I am using Windows for gaming primarily and the games run far better natively.
Thanks again for this great utility.
Thank you very much for this script, I believe it will be very useful to me.
Indeed, I have the same question as matalk: can’t I boot to an other OS while OSX is suspended-to-disk?
I use rEFIt to load my Linux, but it is never loaded: the RAM is restored directly.
That would be so nice to be able to switch from one OS to an other without the booting processβ¦
Great tool!
It work fine on my MacBook Pro with Snow Leopard (10.6.1)
Tnx
Pingback: How to hibernate Mac OS X | Code Mox
Pingback: Como hibernar o Mac | iSengardian
Pingback: Otra opciΓ³n para poner tu Mac a hibernar | Soy de Mac
Hi Sveenie, thanks for this good script.
I’d like to advice about the hibernatemode used, you use the mode 1, that is aceptable, but if we read at pmset manual ($ man pmset) we can read at the hibernatemode section (please everyone read it):
” We do not recommend modifying hibernation settings. Any changes you make
are not supported. If you choose to do so anyway, we recommend using one
of these three settings. For your sake and mine, please don’t use any-
thing other 0, 3, or 25.”
Basically the mode 25 is the same than 1 (hibernation ON, power OFF) but reducing the ammount of RAM written to disk to minimal. I tested this and the time for hibernation and restore is much better than using mode 1, besides the CPU is less used (CPU fan is lesser noisy for lesser time).
So I modified the script to use mode 25 for my own, but I thought you’d like to know for modifing the script for everyone.
Hi Sveenie, I use to have your software working fine in my older Mac OS but when I updated to Mac OS X 10.7.4 it stopped working and I get error message: “exit return_code = 0xe00002c1” do you know how do I fix it? Any help would be fine. Thank you.
I have the same problem, “exit return_code = 0xe00002c1” help?
sadf
The reason for the 0xe00002c1 error is that the command line tool (pmset) needed to enable hibernation requires administrative privileges on Lion and later.
So this tool won’t work on Lion+ as it stands. I think there are alternatives out there. Or you could do it from the command line.
following previous comments regarding error 0xe00002c1 and hibernatemode 25, I slightly modified the script (Right click Hibernate in finder > Show package content, open Contents/Resources/Scripts/main.scpt)
I use:
do shell script “/usr/bin/pmset force -a hibernatemode 25” with administrator privileges
and for the set old value:
do shell script (“/usr/bin/pmset force -a hibernatemode ” & lastMode) with administrator privileges
I only get the password prompt after the “hibernate?” dialogue and it works fine on Mountain Lion π
Fix to Hibernate.App for 10.8 (and, I assume, 10.7)
After upgrading to 10.8 from 10.6 I started getting the “exit return_code = 0xe00002c1”.
After a lot of screwing around, I finally got it to work on 10.8.5. I think this should work on any version of MacOS that gives that error (10.7.x? 10.8.x).
Note: Everything I know about AppleScript and the AppleScript Editor I learned in the past hour or so while developing this fix. There very well may be much better ways to accomplish this.
I had to make two changes:
(1) Adjust the hibernatemode of the pmset program. Apple strongly recommends that the only values that you use are 1, 3, and 25. My Mac had this set to 3. It seems that my fix will work only if this is set to either 1 or 25, BUT NOT 3.
Launch the Terminal app (typically in the Utilities subfolder of Applications in Finder). Then use pmset to adjust the hibernatemode to 25 (as I said, 1 will work also). You will need administrator permission, which is accomplished with the sudo prefix, you will be prompted for your password. (If you do not have the necessary sudo privilege you will need to use the su command, which will require the “superuser” password.)
(1a) Check the current value of hibernatemode:
pmset -g
Look through the output for the hibernatemode value:
Currently in use:
hibernatemode 3
(1b) Next, if this is 3 (or any other value other than 1 or 25) change it to 1 or 25. This sets it to 25:
sudo pmset -a hibernatemode 25
The “-a” tells the system to use this in all modes (battery or AC power).
(1c) Finally, exit from the Terminal:
exit
(2) Fix the AppleScript of the Hibernate.app. To do so, try to hibernate by clicking on the Hibernate launcher icon, and when you get the “exit return_code = 0xe00002c1” message, click on the “EDIT” button. This will open the AppleScript Editor. The last 6 lines of text are:
————————————————————————————-
do shell script “/usr/bin/pmset force -a hibernatemode 1”
ignoring application responses
tell application “System Events” to sleep
delay 5
do shell script (“/usr/bin/pmset force -a hibernatemode ” & lastMode)
end ignoring
————————————————————————————-
Delete these 6 lines and replace them with this one line:
————————————————————————————-
do shell script “/usr/bin/pmset sleepnow”
————————————————————————————-
To save your changes, click the “Run” button (arrow in green circle). You can cancel when it ask “Do you want to hibernate? (suspend-to-disk)” or you can click OK to see that it does work. (This, running it once, was the only way I could find to save the changes).
You should be all set. Clicking on the original launcher icon should now save-to-disk and shut off completely.
————————————————————————————-
NOTE: If the author of this program is interested, these changes could be incorporated into a new version of the program. The script could check the current value of hibernatemode and set it to 1 or 25 (instead of requiring the user to use Terminal and sudo). The AppleScript for this would look like:
do shell script “/usr/bin/pmset -a hibernatemode 1” with administrator privileges
Ideally, this should only be done once the first time the script runs, and then suppressed on subsequent invocations when the value is found to be 1, because it will pop up a prompt for the user’s password.
However, this is beyond my one hour self-taught knowledge of AppleScript.
I had the error code 0xe00002c1 (I’m on Mavericks) but Howie’s changes fixed it perfectly for me, thanks Howie.
Pingback: Die Linkpeitsche XVII
Howie did a good job but he had some mistakes.
ββββββββββββββββββββββββββββ-
do shell script β/usr/bin/pmset force -a hibernatemode 1β³
ignoring application responses
tell application βSystem Eventsβ to sleep
delay 5
do shell script (β/usr/bin/pmset force -a hibernatemode β & lastMode)
end ignoring
ββββββββββββββββββββββββββββ-
is not equal to next code.
ββββββββββββββββββββββββββββ-
do shell script β/usr/bin/pmset sleepnowβ
ββββββββββββββββββββββββββββ-
βpmset sleepnowβ command just perform a immediate sleep.
But original code saves current hibernatemode and then after waking from hibernate, it restores original hibernatemode.
But βdelay 5β is too short so hibernatemode changes to the original value back before hibernating and it doesnβt hibernate.
So modified source is below.
βββββββββββββββββββββββββββββββββ
do shell script “/usr/bin/pmset force -a hibernatemode 25” user name β{USER NAME}β password β{PASSWORD}β with administrator privileges
ignoring application responses
tell application “System Events” to sleep
delay 30
do shell script (“/usr/bin/pmset force -a hibernatemode ” & lastMode) user name β{USER NAME}β password β{PASSWORD}β with administrator privileges
end ignoring
βββββββββββββββββββββββββββββββββ
My mac is 10.9.4 OS X.
If you type “pmset -g” in Terminal App, you will find useful option for hibernate.
βstandbyβ causes kernel power management to automatically hibernate a machine after it has slept for a specified time period. This saves power while asleep.
βstandbydelayβ specifies the delay, in seconds, before writing the hibernation image to disk and powering off memory for Standby.
In Terminal App, you can type the next command.
——————————————————————
sudo pmset -a hibernatemode 3 standby 1 standbydelay 600
——————————————————————
It turns on βstandbyβ and after 600 secondes since sleep, goes into hibernate.