summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-02-06 10:36:16 -0600
committerVictor Lowther <victor.lowther@gmail.com>2008-02-07 13:46:14 -0600
commita92675f0a02396494b7e5d58fa7ea841ccbe0cc5 (patch)
tree4f59d470a47ae0a93fb0cd63bc0a6dda07656c3a /src
parent8df496aeffe3a7114fa01912d7605693c5bc64b9 (diff)
Even simpler modularization of sleep methods.
This splits the actual functions that perform the sleep/wakeup into a file which is sourced, adds an environment variable which controls which module is sourced, moves the check functions into the sleep module, modifies pm-action and pm-is-supported to take these changes into account, and modifies the automake machinery to take these changes into account.
Diffstat (limited to 'src')
-rw-r--r--src/pm-action.in36
-rwxr-xr-xsrc/pm-is-supported.in (renamed from src/pm-is-supported)31
2 files changed, 14 insertions, 53 deletions
diff --git a/src/pm-action.in b/src/pm-action.in
index b9b32dd..23f2749 100644
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -87,40 +87,18 @@ done
export PM_FUNCTIONS="@PM-UTILS-LIBDIR@/functions"
. "${PM_FUNCTIONS}"
-[ -f /sys/power/state ] || exit 1
-
-
-ACTION=${0##*pm-}
+ACTION="$(echo ${0##*pm-} |tr - _)"
case "$ACTION" in
- suspend)
- if ! pm-is-supported --"$ACTION" ; then
- echo "Error: kernel cannot suspend to ram." 1>&2
- exit 1
- fi
- REVERSE=resume
- ;;
- hibernate)
- if ! pm-is-supported --"$ACTION" ; then
- echo "Error: kernel cannot suspend to disk." 1>&2
- exit 1
- fi
- REVERSE=thaw
- ;;
- suspend-hybrid)
- if ! pm-is-supported --"$ACTION" ; then
- echo "Error: hybrid suspend is not supported." 1>&2
- exit
- fi
- REVERSE=resume
- ;;
- *)
- exit 1
- ;;
+ suspend) REVERSE=resume ;;
+ hibernate) REVERSE=thaw ;;
+ suspend_hybrid) REVERSE=resume ;;
+ *) echo "Don't know how to ${ACTION}."
+ exit 1 ;;
esac
export PM_CMDLINE="$@"
-pm_main "$(echo $ACTION | tr - _)" "$REVERSE"
+pm_main "${ACTION}" "{$REVERSE}"
exit $?
diff --git a/src/pm-is-supported b/src/pm-is-supported.in
index 9520e0b..af2f2cf 100755
--- a/src/pm-is-supported
+++ b/src/pm-is-supported.in
@@ -16,38 +16,21 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+. "@PM-UTILS-LIBDIR@/functions"
+
help_options() {
echo "pm-is-supported [--suspend | --hibernate | --suspend-hybrid ]"
echo
}
-export LC_COLLATE=C
-
ARG="${1#--}"
-[ -f /sys/power/state ] || exit 1
-
case "$ARG" in
- suspend)
- grep -q mem /sys/power/state || exit 1
- ;;
- hibernate)
- [ -f /sys/power/disk ] || exit 1
- grep -q disk /sys/power/state || exit 1
- ;;
- suspend-hybrid)
- grep -q mem /sys/power/state || exit 1
- [ -d /sys/power/tuxonice ] && exit 0
- #grep -q disk /sys/power/state || exit 1
- exit 1
- ;;
- help)
- help_options
- ;;
- *)
- help_options 1>&2
- exit 1
- ;;
+ suspend|hibernate|suspend-hybrid)
+ "check_$ARG"; exit $? ;;
+ help) help_options ;;
+ *) help_options 1>&2
+ exit 1 ;;
esac
exit 0