[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to hibernate from the command line without typing password



I asked this question on this list a while back and although I did get a
helpful response that would have led to a solution, it would not have
led to the better solution that I recently discovered so I thought I'd
post this in case it might be helpful to anyone else searching the list.

I found the solution in this blog post:

http://thehacklist.blogspot.com/2009/09/suspendhibernate-from-command-line.html

the command in the post itself didn't work for me, but one given in the
comments did. This works for me in Debian Lenny running the default
Gnome desktop. You can send a signal via dbus asking for the computer to
be hibernated with the following command:

    dbus-send --session --dest=org.freedesktop.PowerManagement --type=method_call /org/freedesktop/PowerManagement org.freedesktop.PowerM    anagement.Hibernate

In the above blog post's comments you'll find a similar command to
suspend the computer.

I used this command to add a one-click hibernate button to my Gnome
panel (as a custom application launcher). Normally you can't hibernate
without multiple clicks in Gnome, and it always asks you whether you
want to suspend, hibernate, restart or shutdown, of which shutdown seems
to always be the default. I just kept choosing shutdown and then cursing
because what I always want is to hibernate. If hibernate works for you,
why would you ever want to shutdown? Hibernate seems to me to be what
computers should always do, as they start up much faster and all your
context is preserved.

I also saved the command as an executable script called 'hibernate' so
that I can hibernate from the command line by just typing hibernate.

Works for me!


Reply to: