On Tue, 2008-07-01 at 20:59 -0500, Victor Lowther wrote:
> On Tue, 2008-07-01 at 17:10 +0200, Stefan Seyfried wrote:
> > Hi,
> > 
> > Victor Lowther wrote:
> > > Does just passing $METHOD as the second parameter work for you?
> > 
> > Yes, it's even easier ;-)
> 
> We have a plan.

Code to implement two-parameter sleep hooks (against fd.o git master):

 pm/HOWTO.hooks    |   18 +++++++++++-------
 pm/sleep.d/01grub |    5 +++--
 src/pm-action.in  |    4 ++--
 3 files changed, 16 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/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 58a20b6..c5b560c 100755
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -82,7 +82,7 @@ rm -f "${INHIBIT}"
 
 # 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
@@ -93,7 +93,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

It is also available as the two-parameter-sleep-hooks branch in fd.o
git:
http://cgit.freedesktop.org/pm-utils/log/?h=two-parameter-sleep-hooks

If there are no objections, I will include it in the 1.2 pm-utils
series.

> > Thanks,
> > 
> >     Stefan
-- 
Victor Lowther
Ubuntu Certified Professional

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to