Pressing Power Button should Hibernate (suspend-to-disk) system

Alexander Skwar listen at alexander.skwar.name
Wed Jul 5 19:44:15 UTC 2006


I worte:

> I'd like to setup the system so, that when I press the power button
> for a /short/ time, the system should "Hibernate", ie. suspend-to-disk.
> It should do so, by executing /usr/sbin/hibernate. And when I keep the
> power button pushed for a /long/ time, the system should shut down.
> 
> Right now, when I push the power button shortly, the system shuts down.

That the system did a shutdown, was some sort of bug. I now "Windows
fixed" it (ie. I reinstalled it), and that bug is gone. When I now push
the power button, the Gnome logout dialog shows. When I press cancel, the
dialog is cancelled; when I press "Hibernate", the system would hibernate.

*BUT*: It would *NOT* use the /usr/sbin/hibernate script to do so. The
scripts associated with those buttons can be displayed by doing

hal-get-property --udi /org/freedesktop/Hal/devices/computer \
    --key org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths

Those are scripts, which are stored in /usr/share/hal/scripts; for hibernate,
it would be /usr/share/hal/scripts/hal-system-power-hibernate.

What this does, I just described on the gnome-power-manager list. I'll
copy and paste my analysis for the benefit of *this* list and would
like to get comments from you:

*********************************


This seems to be true - a distribution doesn't *HAVE* to have
those files. Just as Andrew wrote, the scripts referenced by

hal-get-property --udi /org/freedesktop/Hal/devices/computer \
      --key org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths

get executed. Just as it is on FC5, on Ubuntu there's a
/usr/share/hal/scripts/hal-system-power-hibernate. And in that file,
there's "#Other distros just need to have *any* tools installed",
see <http://askwar.pastebin.ca/79817>, line 31ff.

Now I'd need a way to configure the order in which those scripts
get executed or configure *directly*, which script gets run.
Reason: I want /usr/sbin/hibernate, NOT pmi. But I cannot
remove /usr/sbin/pmi, as it belongs to a package on which g-p-m
and gnome-session depend. Sure, I could rm the file. But... Naaa....  :)

I now did some more debugging or looked closer (call it what you
like) and saw, that eventually "/usr/sbin/pmi action hibernate force"
would get executed (<http://askwar.pastebin.ca/79831>). And to make
the system hibernate, pmi executes /etc/acpi/hibernate.sh, which you
can find on <http://askwar.pastebin.ca/79832>. And *THIS* is finally
the script, which will make the system hibernate - *phew*, what a
chain of scripts....

But to make the system hibernate, hibernate.sh will do:

echo -n $HIBERNATE_MODE >/sys/power/disk
echo -n "disk" >/sys/power/state

As I said, that's not what I want. I'd want, that /usr/sbin/hibernate
get's run. And IMO the easiest and most straight forward way would
be, if g-p-m could be told what script to execute. Maybe using gconf?

But as it is right now, there's no way to configure the system, is there?
I mean, the only way would be to edit one of the scripts; /etc/acpi/hibernate.sh,
I'd suppose, as that's in /etc.

Or is there any other way?
**************************************************

Well, as I wrote there, I'd be interested in finding out how to
configure what g-p-m does, when e.g. the "Hibernate" button is
pressed.

Hmmm... Would the correct way be, to modify the key "org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths"
under the udi "/org/freedesktop/Hal/devices/computer"? How?
It's a string list. I tried:

alexander at knospe:/var/log$ hal-set-property --udi /org/freedesktop/Hal/devices/computer --key org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths --strlist-post /usr/sbin/hibernate

Ah. That worked - fine :) But it's now at the wrong position (last), I guess.
I guess it needs to be the *2nd* item in the list. How can I get it there?
Are there other tools to modify hal? Is it okay to give a full path there,
or MUST the script be in /usr/share/hal/scripts/?

How to do that?

Thanks,
Alexander




More information about the ubuntu-users mailing list