summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-02-13 20:52:34 -0600
committerVictor Lowther <victor.lowther@gmail.com>2008-02-13 20:52:34 -0600
commit4d455cec32aefbd9bbc89587fb5676e280e76914 (patch)
tree858f2f7f9933af51a8e1b2813ccec3a7262b787f /src
parent30ce87e6e801060653b450f5452619eb47f63082 (diff)
parent03a59b39d415366cb7068886f103db8fa6ef6aac (diff)
Merge branch 'master' into vlowther-move-pm-main
Conflicts: pm/functions.in src/pm-action.in
Diffstat (limited to 'src')
-rwxr-xr-xsrc/on_ac_power6
-rw-r--r--src/pm-action.in38
-rw-r--r--[-rwxr-xr-x]src/pm-is-supported.in (renamed from src/pm-is-supported)33
-rw-r--r--src/pm-powersave.in2
4 files changed, 21 insertions, 58 deletions
diff --git a/src/on_ac_power b/src/on_ac_power
index 6f6a3d0..edddf72 100755
--- a/src/on_ac_power
+++ b/src/on_ac_power
@@ -31,7 +31,7 @@
#
# Check for AC/DC/etc adapters
-ac_adapters=$(hal-find-by-capability --capability ac_adapter)
+ac_adapters="$(hal-find-by-capability --capability ac_adapter)"
# If there are no AC adapters, it is most likely a desktop.
# Assume online, since we have no data.
@@ -39,8 +39,8 @@ ac_adapters=$(hal-find-by-capability --capability ac_adapter)
# If any of them are online, then we're done.
for device in $ac_adapters ; do
- present=$(hal-get-property --udi "$device" --key ac_adapter.present)
- [ "x$present" = "xtrue" ] && exit 0
+ present="$(hal-get-property --udi "$device" --key ac_adapter.present)"
+ [ "$present" = "true" ] && exit 0
done
# If there are adapters, but none are online, we're not on AC.
diff --git a/src/pm-action.in b/src/pm-action.in
index b1a8bf6..894b50b 100644
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -87,36 +87,14 @@ 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="$@"
@@ -125,6 +103,8 @@ take_suspend_lock || exit 1
trap remove_suspend_lock 0
init_logfile "${PM_LOGFILE}"
rm -f "${INHIBIT}"
-run_hooks sleep "$(echo $ACTION | tr - _)" reverse "$REVERSE"
+run_hooks sleep $ACTION
+"do_$ACTION"
+reverse "$REVERSE"
exit $?
diff --git a/src/pm-is-supported b/src/pm-is-supported.in
index 9520e0b..62947f7 100755..100644
--- 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
+ARG="$(echo ${1#--}|tr - _)"
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
diff --git a/src/pm-powersave.in b/src/pm-powersave.in
index f6cea14..5098cf8 100644
--- a/src/pm-powersave.in
+++ b/src/pm-powersave.in
@@ -28,7 +28,7 @@ POWERSAVE_LOGFILE="/dev/null"
export PM_FUNCTIONS="@PM-UTILS-LIBDIR@/functions"
. "${PM_FUNCTIONS}"
-if [ "x$1" = "xtrue" -o "x$1" = "xfalse" ] ; then
+if [ "$1" = "true" -o "$1" = "false" ] ; then
init_logfile "${POWERSAVE_LOGFILE}"
run_hooks power "$1"
else