Inspiration & Genius – One and the Same

Control your hibernation state more easily from Terminal.app

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.

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Genesis Framework

Genesis Framework for WordPress

Studiopress Themes

Scribble Theme - A Beautiful Frame For Your WordPress Website

Advertisements