Did this by adding a log() function and using that instead of echo when
we were just echoing test to get it into the log.
---
 pm/functions.in    |   17 ++++++++++-------
 pm/sleep.d/99video |    1 +
 src/pm-action.in   |    8 +-------
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/pm/functions.in b/pm/functions.in
index 33e5a85..ca67ad8 100644
--- a/pm/functions.in
+++ b/pm/functions.in
@@ -34,6 +34,8 @@ export LC_COLLATE=C
 
 set +a
 
+log() { [ $LOGGING ] && echo $*; }
+
 source_configs()
 {
        for cfg in "${PM_UTILS_ETCDIR}"/config.d/*[!~] ; do
@@ -48,7 +50,7 @@ source_configs
 
 SLEEP_FUNCTIONS="${PM_UTILS_LIBDIR}/module.d/${SLEEP_MODULE}"
 [ -f "${SLEEP_FUNCTIONS}" ] || { 
-       echo "Requested sleep module $SLEEP_MODULE not available."
+       log "Requested sleep module $SLEEP_MODULE not available."
        exit 1
 }
 
@@ -121,9 +123,9 @@ command_exists()
 
 hook_exit_status(){
        case $1 in
-               0) echo "success." ;;
-               $NA) echo "not applicable." ;;
-               *) echo "Returned exit code $1." ;;
+               0) log "success." ;;
+               $NA) log "not applicable." ;;
+               *) log "Returned exit code $1." ;;
        esac
 }
 
@@ -153,7 +155,7 @@ run_hooks() {
                fi
                [ -x "${hook}" ] && (
                        IFS="${oifs}"
-                       echo "$(date): running ${hook} $2"
+                       log "$(date): running ${hook} $2"
                        "${hook}" $2
                        hook_exit_status $?
                )
@@ -192,6 +194,7 @@ init_logfile()
                echo "Please pass a filename to init_logfile."
                return 1
        fi
+       export LOGGING="true"
        exec > "$1" 2>&1
 }
 
@@ -222,7 +225,7 @@ _rmmod()
                touch "${STORAGEDIR}/module:$1"
                return 0
        else
-               echo "# could not unload '$1', usage count was $2"
+               log "# could not unload '$1', usage count was $2"
                return 1
        fi
 }
@@ -278,7 +281,7 @@ if ! command_exists service; then
                        shift
                        "/etc/init.d/$svc" "$@"
                else
-                       echo "$1" $": unrecognized service" 1>&2
+                       log "$1" $": unrecognized service" 1>&2
                        return 1
                fi
        }
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index e215e9d..53700fc 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -115,6 +115,7 @@ resume_video()
 }
 
 help() {
+       echo  # first echo makes it look nicer.
        echo "Video quirk handler options:"
        echo
        echo "  --quirk-dpms-on"
diff --git a/src/pm-action.in b/src/pm-action.in
index 9012802..fe8ed6a 100644
--- a/src/pm-action.in
+++ b/src/pm-action.in
@@ -35,13 +35,7 @@ help()
 {
        echo "${0##*/} [options]"
        echo
-       echo "Options can change how the supend or hibernate is done."
-       echo "pm-utils by itself does not handle any options except --help."
-       echo
-       echo "Instead, any options you supply are passed on to the helper"
-       echo "progams that handle the details of power management."
-       echo
-       echo "Those options are:"
+       echo "Options can change how suspend or hibernate is done."
        run_hooks sleep help
        exit 0
 }
-- 
1.5.4.3

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to