[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'.

Jason


# -*- 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
    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."
        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
}



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

Reply via email to