2014/01/21

Suspending and Hibernating on Slackware:

It is very straightforward to make Slackware suspend to RAM or hibernate to disk using D-Bus. D-Bus is a message bus system, that allows applications communicate.

On Slackware, make sure your user is on power group. Check with:

$ groups your_user

Change your_user to your user name. If it is not in power group, add with

# usermod -aG power your_user

Suspending

In order to suspend to RAM, just run the following command from a user on power group:

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Hibernating

CAUTION: this method does not work if you use [LVM extlink en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)]. If you do, take a look at external links at the end of the post.

The command to hibernate to hard disk is similar to the hibernating command:

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate

But, for the bootloader to know where to find the state saved on disk during hibernation, you'll need to tell it. On /etc/lilo.conf, append the line append="resume=/dev/sdX":

image = /boot/vmlinuz
 root = /dev/sdaY
 initrd = /boot/initrd.gz
 label = Slackware
 read-only
 append = "resume=/dev/sdaX

where /dev/sdaX is the swap partition.

Run

# lilo

to apply changes.

Just a Lil' Problem

When you suspend or hibernate only with those commands, when the computer restarts, your session will be unlocked.

To avoid it, call a lock or screensaver before taking those actions. I use xscreensaver and have the scripts dbus-suspend dbus-hibernate to lock computer:

xscreensaver-command -lock
sleep 7
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate

Rebooting and Halting

With D-Bus, if you are in power group, you can reboot or halt your system too:

To reboot your system:

$ dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart

And to halt:

$ dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

Revision History

Post built on: 2014-01-21 00:28:26
Last modified on: 2014-01-21 00:28:22
First published on: 2014-01-21

Revision Date Description
1.00 2014-01-09 Initial Version. Published.

No comments :

Post a Comment