summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-07-10 13:49:34 -0500
committerVictor Lowther <victor.lowther@gmail.com>2008-07-10 13:49:34 -0500
commit6ec54f84dd4dcc0ed1f670cdcb1894f4ed6a6239 (patch)
treea01b39f238d7e9a129ca99554f3bedeb9a2c967e
parentf76baff97225aa45221d553b7541d3e4db953a04 (diff)
parent873733dad6476a7c5f7ec6068fb0be7b4c62edbb (diff)
Merge branch 'two-parameter-sleep-hooks'
-rw-r--r--pm/HOWTO.hooks18
-rwxr-xr-xpm/module.d/tuxonice3
-rw-r--r--pm/sleep.d/01grub5
-rwxr-xr-xsrc/pm-action.in4
4 files changed, 19 insertions, 11 deletions
diff --git a/pm/HOWTO.hooks b/pm/HOWTO.hooks
index 816ebba..bf68813 100644
--- a/pm/HOWTO.hooks
+++ b/pm/HOWTO.hooks
@@ -2,24 +2,28 @@ How to write a pm-utils hook:
PARAMETERS
-A pm-utils hook is simply an executable file that accepts a single parameter.
-For hooks in sleep.d, the potential values of that parameter are:
+A pm-utils hook is simply an executable file that accepts at least one
+parameter.
+
+For hooks in sleep.d, the potential values of the first parameter are:
suspend -- The hook MUST perform whatever action is appropriate when the
- system is preparing for S3 sleep (or its equivalent).
-suspend_hybrid -- The hook MUST perform whatever action is appropriate
- when entering suspend mode. The hook SHOULD also save
- any state it may need to bring the system back from
- hibernate mode.
+ system is preparing for memory sleep (or its equivalent).
resume -- The hook MUST perform whatever action is appropriate when the
system is coming out of suspend.
+
hibernate -- The hook MUST perform whatever action is appropriate when
the system is preparing for suspend-to-disk.
thaw -- The hook MUST perform whatever action is appropriate when the system
is coming out of suspend-to-disk.
+
help -- If your hook parses the PM_CMDLINE environment variable for switches,
this function SHOULD output text describing the parameters it parses
in a format easily understandable by an end-user.
+The actual sleep method being used will be passed as the second parameter --
+if your hook needs to handle suspend-hybrid (or any other platform-specific
+sleep method), it should examine the second parameter.
+
For hooks in power.d, the potential values of that parameter are:
true -- the hook MUST perform whatever action is appropriate when the system
transitions TO battery power.
diff --git a/pm/module.d/tuxonice b/pm/module.d/tuxonice
index 32d7584..57b7bb8 100755
--- a/pm/module.d/tuxonice
+++ b/pm/module.d/tuxonice
@@ -45,4 +45,7 @@ do_suspend_hybrid()
{
echo 3 >"${TUXONICE_LOC}/powerdown_method"
echo anything >"${TUXONICE_LOC}/do_hibernate"
+ [ -f /sys/power/tuxonice/did_suspend_to_both ] && \
+ [ "$(cat /sys/power/tuxonice/did_suspend_to_both)" != "1" ] && \
+ REVERSE="thaw"
}
diff --git a/pm/sleep.d/01grub b/pm/sleep.d/01grub
index 096ffa7..db1d53b 100644
--- a/pm/sleep.d/01grub
+++ b/pm/sleep.d/01grub
@@ -4,6 +4,7 @@
default_resume_kernel()
{
+ [ "$1" = "suspend" ] && return $NA
case $(uname -m) in
i?86|x86_64|athlon)
;;
@@ -25,8 +26,8 @@ default_resume_kernel()
}
case "$1" in
- hibernate|suspend_hybrid)
- default_resume_kernel
+ hibernate|suspend)
+ default_resume_kernel $2
;;
*) exit $NA
;;
diff --git a/src/pm-action.in b/src/pm-action.in
index e756793..bc83b3c 100755
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -93,7 +93,7 @@ load_hook_parameters
# run the sleep hooks
log "$(date): Running hooks for $ACTION."
-if run_hooks sleep "$ACTION"; then
+if run_hooks sleep "$ACTION $METHOD"; then
# Sleep only if we know how and if a hook did not inhibit us.
log "$(date): performing $METHOD"
sync
@@ -104,7 +104,7 @@ else
fi
log "$(date): Running hooks for $REVERSE"
# run the sleep hooks in reverse with the wakeup action
-if run_hooks sleep "$REVERSE" reverse; then
+if run_hooks sleep "$REVERSE $METHOD" reverse; then
log "$(date): Finished."
else
exit 1