Control your hibernation state more easily from Terminal.app
admin | Jun 20, 2009 | Comments 0
From http://www.commandlinefu.com by thebillywayne
The command below is a function and should be placed in your bash environmental file.
The author often changed his MacBook’s sleep state. So he created a function for bash to make it a little easier.
Usage:
hibernate (on | off)
"hibernate on" will set your laptop to hibernate if the lid is closed.
"hibernate off" will set your laptop to sleep if the lid is closed.
### note : “proper” indentation isn’t preserved on the website
<START CODE>
function hibernate()
{
case "${1}" in
on)
sudo pmset -a hibernatemode 1
echo Hibernate mode on.
;;
off)
sudo pmset -a hibernatemode 0
echo Hiberate mode off.
;;
*)
echo "I'm sorry Dave, but I can't do that."
;;
esac
}
<END CODE>
To make things easier, add the proper line in your /etc/sudoers file so that your user may invoke pmset without a password. Here’s how it should look:
me mycomputer = NOPASSWD: /usr/bin/pmset
Don’t forget that you must edit sudoers with `sudo visudo` from Terminal.app, and not by another text editor.
Filed Under: Tech
About the Author: I am the I.T. Director and Information Security Officer for an ecommerce / production company. I'm also a graphic designer; musician; martial arts instructor; pilot and all around creative genius.





