summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2010-06-04 11:56:11 -0500
committerVictor Lowther <victor.lowther@gmail.com>2010-06-05 13:46:06 -0500
commit58a67a9cbb8637c8cfe4ea06d5d956af0704f498 (patch)
tree12bb34282fda9b9510fbc3fcf296cbc6d4487933 /src
parent32b72f406ad5bf92dddb2092082891f8225618f4 (diff)
Add help functionality to pm-powersave
Diffstat (limited to 'src')
-rw-r--r--src/pm-powersave.in57
1 files changed, 37 insertions, 20 deletions
diff --git a/src/pm-powersave.in b/src/pm-powersave.in
index 08e4f5b..7399788 100644
--- a/src/pm-powersave.in
+++ b/src/pm-powersave.in
@@ -31,27 +31,44 @@ remove_powersave_lock() {
release_lock "${STASHNAME}.lock"
}
-# take the powersave lock.
-# ensure it gets released no matter how we exit.
-try_lock "${STASHNAME}.lock" || exit 1
-trap remove_powersave_lock 0
-mkdir -p "${STORAGEDIR}"
-rm -f "${INHIBIT}"
+help() {
+ cat <<EOF
+$0: Valid options are:
+false or ac = turn powersaving features off.
+true or battery = turn powersaving features on.
+help = get detailed help.
-load_hook_blacklist
+EOF
+if [ "$1" = "--help" ]; then
+ cat <<EOF
+The rest of this help message displays the variables
+that can be used to tune the powersave hooks.
+You can change these variables using pm-utils config files.
+(see the pm-utils README for more information)
-if [ "$1" = "true" -o "$1" = "false" ] ; then
- init_logfile "${PM_LOGFILE}"
- run_hooks power "$1"
-elif [ ! "$1" ]; then
- # no arg? Guess!
- init_logfile "${PM_LOGFILE}"
- if on_ac_power; then
- run_hooks power false;
- else
- run_hooks power true;
- fi
+EOF
else
- echo "Argument needs to be true or false" >&2
- exit 1
+ echo "You can get more detailed information by running pm-powersave --help"
fi
+}
+
+lock_and_load() {
+# take the powersave lock.
+# ensure it gets released no matter how we exit.
+ try_lock "${STASHNAME}.lock" || exit 1
+ trap remove_powersave_lock 0
+ mkdir -p "${STORAGEDIR}"
+ rm -f "${INHIBIT}"
+
+ load_hook_blacklist
+
+ init_logfile "${PM_LOGFILE}"
+}
+
+case $1 in
+ true|battery) lock_and_load && run_hooks power true;;
+ false|ac) lock_and_load && run_hooks power false;;
+ --help) help && run_hooks power help;;
+ '') lock_and_load; on_ac_power && run_hooks power false || run_hooks power true;;
+ *) help && exit 1;;
+esac