[Pm-utils] [PATCH 3/6] Make per-module help and before_hooks methods stackable.
Victor Lowther
victor.lowther at gmail.com
Wed Sep 17 20:22:48 PDT 2008
This will help with making the sleep methods stackable and
autodetectable.
---
pm/module.d/uswsusp | 13 ++++++++-----
pm/pm-functions.in | 31 ++++++++++++++++++++++++++++++-
src/pm-action.in | 2 +-
3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/pm/module.d/uswsusp b/pm/module.d/uswsusp
index 4647824..615da3a 100755
--- a/pm/module.d/uswsusp
+++ b/pm/module.d/uswsusp
@@ -1,13 +1,13 @@
#!/bin/sh
# disable processing of 99video
-before_hooks()
+uswsusp_hooks()
{
disablehook 90chvt "disabled by uswsusp"
disablehook 99video "disabled by uswsusp"
}
-get_quirks()
+uswsusp_get_quirks()
{
OPTS=""
ACPI_SLEEP=0
@@ -41,7 +41,7 @@ check_suspend()
do_suspend()
{
- get_quirks
+ uswsusp_get_quirks
s2ram --force $OPTS
}
@@ -67,11 +67,11 @@ check_suspend_hybrid()
do_suspend_hybrid()
{
- get_quirks
+ uswsusp_get_quirks
s2both --force $OPTS
}
-sleep_method_help()
+uswsusp_help()
{
echo # first echo makes it look nicer.
echo "Video quirk handler options:"
@@ -89,3 +89,6 @@ sleep_method_help()
echo " --quirk-save-pci"
echo " --quirk-none"
}
+
+add_module_help uswsusp_help
+add_before_hooks uswsusp_hooks
diff --git a/pm/pm-functions.in b/pm/pm-functions.in
index f7492a0..a9c8912 100644
--- a/pm/pm-functions.in
+++ b/pm/pm-functions.in
@@ -44,6 +44,8 @@ DROP_PARAMETERS=""
PARAMETERS="${STORAGEDIR}/parameters"
INHIBIT="${STORAGEDIR}/inhibit"
PM_CMDLINE="$*"
+BEFORE_HOOKS=""
+MODULE_HELP=""
# when loading configuration files, allow stash-specific ones
# to override the pm-utils global ones.
@@ -90,6 +92,34 @@ log()
printf "$fmt" "$*"
}
+add_before_hooks() {
+ [ -z "$BEFORE_HOOKS" ] && BEFORE_HOOKS="$*" || \
+ BEFORE_HOOKS="$BEFORE_HOOKS $*"
+}
+
+add_module_help() {
+ [ -z "$MODULE_HELP" ] && MODULE_HELP="$*" || \
+ MODULE_HELP="$MODULE_HELP $*"
+}
+
+before_hooks()
+{
+ [ -z "$BEFORE_HOOKS" ] && return 0
+ local meth
+ for meth in $BEFORE_HOOKS; do
+ command_exists "$meth" && "$meth"
+ done
+}
+
+sleep_module_help()
+{
+ [ -z "$MODULE_HELP" ] && return 0
+ local meth
+ for meth in $MODULE_HELP; do
+ command_exists "$meth" && "$meth"
+ done
+}
+
# update PM_CMDLINE iff someone changed our parameters
update_parameters()
{
@@ -203,7 +233,6 @@ init_logfile()
exec > "$1" 2>&1
}
-
SLEEP_FUNCTIONS="${PM_UTILS_LIBDIR}/module.d/${SLEEP_MODULE}"
[ -f "${SLEEP_FUNCTIONS}" ] || {
echo "Requested sleep module $SLEEP_MODULE not available."
diff --git a/src/pm-action.in b/src/pm-action.in
index 5e7ca87..b9e5a21 100755
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -35,7 +35,7 @@ help()
echo
echo "Options can change how suspend or hibernate is done."
run_hooks sleep help
- command_exists sleep_method_help && sleep_method_help
+ sleep_method_help
exit 0
}
--
1.5.6.5
More information about the Pm-utils
mailing list