diff options
-rwxr-xr-x | make-arch-pkg | 2 | ||||
-rw-r--r-- | src/pm-powersave.in | 57 |
2 files changed, 38 insertions, 21 deletions
diff --git a/make-arch-pkg b/make-arch-pkg index 569f6d5..908daa2 100755 --- a/make-arch-pkg +++ b/make-arch-pkg @@ -1,4 +1,4 @@ #!/bin/sh git clean -f -x -d -makepkg && pacman -U pm-utils-git-*.pkg.*
\ No newline at end of file +makepkg && sudo pacman -U pm-utils-git-*.pkg.*
\ No newline at end of file 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 |