On Feb 2, 2008 3:57 PM, Dan Nicholson <[EMAIL PROTECTED]> wrote:
> On Feb 2, 2008 7:16 AM, Michael Biebl <[EMAIL PROTECTED]> wrote:
> > I don't think we should overwrite the do_suspend/do_hibernate methods.
> > As I outlined in a previous mail, I'd add a
> > (suspend,hibernate)_method() function, that either return the value of
> > the (SUSPEND,HIBERNATE)_METHOD config variable or otherwise check for
> > tuxonice, userspace or kernel support and return a corresponding
> > string.
> > In pm_action you would then simply call pm_suspend_$method.
> > The do_suspend_(tuxonice,userpace,whatever) functions could either be
> > defined in functions, or if you prefer to keep them separate in
> > functions.d/. config.d doesn't seem to be the right place for this to
> > me.
>
> IMO, this is the way to go. *_METHOD in config just controls which
> real do_$action function is called:
>
> # ensure var is set to something
> : ${SUSPEND_METHOD:=kernel}
> do_suspend()
> {
> case "$SUSPEND_METHOD" in
> kernel)
> do_suspend_kernel ;;
> tuxonice)
> do_suspend_tuxonice ;;
> ...
> *)
> echo "Invalid suspend method '$SUSPEND_METHOD'"
> return 1
> ;;
> esac
> }
>
Hmmm... how about something along these lines:
@PM-UTILS-LIBDIR@/methods.d/, which is populated by files named
suspend_method-suspend_type (kernel-suspend, kernel-hibernate,
tuxonice-suspend-hybrid, etc.)
These files accept a single argument, which (right now) can be
either "inhibited" or "", and output either of "resume" or "thaw" on
stdout, depending on whether the system is resuming from suspend or
hibernate.
All the do_suspend_type functions then collapse into a single
do_sleep() function, which is passed either "hibernate", "suspend", or
"suspend-hybrid". The do_sleep method then calls
@PM-UTILS-LIBDIR@/method.d/${SUSPEND_METHOD}-$1 with the appropriate
value of inhibit
That way, there is no patching of case statements needed to add a new
suspend method -- just drop an appropriatly-named script in the
method.d directory, and let it handle doing The Right Thing.
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils