Il Wed, Jun 14, 2006 at 04:20:25PM +0000, Jason Lunz ha scritto: 
> [EMAIL PROTECTED] said:
> > [EMAIL PROTECTED] said:
> >> Or if somebody wants to make a scriptlet to support it (use the
> >> sysfs_power_state scriptlet as a guide), I'll happily merge it for
> >> the next release.
> >
> > That's exactly what I did. I'll post it tonight when my laptop's on.
> > It's completely straightforward.
> 
> Here's the scriptlet I'm currently using. It's adapted from
> the sysfs_power_state scriptlet. I've tried to future-proof it by
> calling the 'suspend' program 's2disk'.

Hi Jason,
I'm familiar with hibernate script, but I see a couple of minor issues:

> # -*- sh -*-
> # vim:ft=sh:ts=8:sw=4:noet
> 
> AddConfigHandler USuspendConfigEnabler
> AddOptionHandler USuspendOptionHandler
> 
> AddConfigHelp "UseUSuspend" "Enables the use of the 's2disk' program for 
> suspending the machine. This requires a kernel supporting the /dev/snapshot 
> interface."
> 
> AddShortOption "n"
> AddLongOption "no-suspend"
> AddOptionHelp "-n, --no-suspend (requires UseUSuspend to be set)" "Disables 
> actually suspending the system. This is useful for testing the suspend script 
> itself."
> 
> SUSPEND_PROG=/usr/local/sbin/s2disk
> SUSPEND_STATE_FILE=/sys/power/state
> 
> USuspendConfigEnabler() {
>     [ "$1" != "useususpend" ] && return 1
>     [ -n "$USING_SUSPEND_STATE" ] && return 0
>     UsingSuspendMethod new_suspend
>     AddSuspendHook 10 EnsureUSuspendCapable
>     AddSuspendHook 99 DoUSuspend
>     USING_SUSPEND_STATE=$2
>     return 0
> }
> 
> USuspendOptionHandler() {
>     [ -z "$USING_SUSPEND_STATE" ] && return 1
>     case $1 in
>       -n|--no-suspend)
>           SUSPEND_STATE_NO_SUSPEND=1
>           ;;
>       *)
>           return 1
>     esac
>     return 0
> }
> 
> DoUSuspend() {
>     if [ -z "$SUSPEND_STATE_NO_SUSPEND" ] ; then
>       vecho 1 "$EXE: Running $SUSPEND_PROG ..."
>       $SUSPEND_PROG

suspend may fail, yet you don't propagate the return value. Is this
correct?

>     else
>       vecho 1 "$EXE: Not actually suspending (--no-suspend given)"
>     fi
>     return 0
> }
> 
> # EnsureUSuspendCapable: makes sure we have /sys/power/state and that
> # the selection option is one of the available suspend modes.
> EnsureUSuspendCapable() {
>     if ! test -f $SUSPEND_PROG ; then
>       vecho 0 "Your kernel does not have $SUSPEND_PROG."

It's not really kernel fault here ;)
Also in this function you may want to check for /dev/snapshot as well.

>       return 2
>     fi
>     if ! test -f $SUSPEND_STATE_FILE ; then
>       vecho 0 "Your kernel does not have power management built in."
>       return 2
>     fi
> 
>     return 0
> }


Luca
-- 
Home: http://kronoz.cjb.net
Soltanto un istante...
tuffarsi nell'infinito...
annegare senza pensieri


_______________________________________________
Suspend-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to