From df278aba456f44fe4573c60ba0d524370ee5ad96 Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Wed, 27 Feb 2008 20:01:14 -0600 Subject: Added support for DISPLAY_QUIRK_NONE to pm-action.in. --- src/pm-action.in | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pm-action.in') diff --git a/src/pm-action.in b/src/pm-action.in index e48b9c2..ed537ca 100644 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -44,6 +44,7 @@ help_options() echo " --quirk-vbemode-restore" echo " --quirk-vbestate-restore" echo " --quirk-vga-mode3" + echo " --quirk-none" echo } @@ -76,6 +77,8 @@ do export DISPLAY_QUIRK_VBESTATE_RESTORE="true" ;; --quirk-vga-mode3) export DISPLAY_QUIRK_VGA_MODE_3="true" ;; + --quirk-none) + export DISPLAY_QUIRK_NONE="true" ;; --help) help_options exit 0 ;; -- cgit v1.2.3 From fda3bb71c9e4d4fbfc730d1277085e241475ceb1 Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Sat, 1 Mar 2008 09:02:41 -0600 Subject: Shortened quirk environment varialbe names. Also made option handling code in pm-action easier to read. --- pm/sleep.d/99video | 28 ++++++++++++++-------------- src/pm-action.in | 47 +++++++++++++++++------------------------------ 2 files changed, 31 insertions(+), 44 deletions(-) (limited to 'src/pm-action.in') diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video index 67f11e5..8c680ca 100755 --- a/pm/sleep.d/99video +++ b/pm/sleep.d/99video @@ -51,51 +51,51 @@ resume_fbcon() quirk() { - [ "$1" = "true" ] && [ -z $DISPLAY_QUIRK_NONE ] + [ "$1" = "true" ] && [ -z $QUIRK_NONE ] } suspend_video() { # 0=nothing, 1=s3_bios, 2=s3_mode, 3=both local acpi_flag=0 - [ "${DISPLAY_QUIRK_S3_BIOS}" = "true" ] && acpi_flag=$(($acpi_flag + 1)) - [ "${DISPLAY_QUIRK_S3_MODE}" = "true" ] && acpi_flag=$(($acpi_flag + 2)) + [ "${QUIRK_S3_BIOS}" = "true" ] && acpi_flag=$(($acpi_flag + 1)) + [ "${QUIRK_S3_MODE}" = "true" ] && acpi_flag=$(($acpi_flag + 2)) sysctl -w kernel.acpi_video_flags=$acpi_flag # We might need to do one or many of these quirks - quirk "${DISPLAY_QUIRK_VBESTATE_RESTORE}" && \ + quirk "${QUIRK_VBESTATE_RESTORE}" && \ vbe vbestate save |savestate vbestate - quirk "${DISPLAY_QUIRK_VBEMODE_RESTORE}" && \ + quirk "${QUIRK_VBEMODE_RESTORE}" && \ vbe vbemode get |savestate vbemode - quirk "${DISPLAY_QUIRK_RADEON_OFF}" && { + quirk "${QUIRK_RADEON_OFF}" && { radeon dac off radeon light off } - quirk "${DISPLAY_QUIRK_VGA_MODE_3}" && \ + quirk "${QUIRK_VGA_MODE_3}" && \ vbe vbemode set 3 - quirk "${DISPLAY_QUIRK_DPMS_SUSPEND}" && \ + quirk "${QUIRK_DPMS_SUSPEND}" && \ vbe dpms suspend save_fbcon } resume_video() { # We might need to do one or many of these quirks - quirk "${DISPLAY_QUIRK_VBE_POST}" && { + quirk "${QUIRK_VBE_POST}" && { vbe post sleep 0.1 } - quirk "${DISPLAY_QUIRK_VBESTATE_RESTORE}" && \ + quirk "${QUIRK_VBESTATE_RESTORE}" && \ restorestate vbestate |vbe vbestate restore - quirk "${DISPLAY_QUIRK_VBEMODE_RESTORE}" && \ + quirk "${QUIRK_VBEMODE_RESTORE}" && \ vbe vbemode set "$(restorestate vbemode)" # based on data from s2ram resume_fbcon - quirk "${DISPLAY_QUIRK_RADEON_OFF}" && { + quirk "${QUIRK_RADEON_OFF}" && { radeon dac on radeon light on } - quirk "${DISPLAY_QUIRK_DPMS_ON}" && \ + quirk "${QUIRK_DPMS_ON}" && \ vbe dpms on - quirk "${DISPLAY_QUIRK_RESET_BRIGHTNESS}" && \ + quirk "${QUIRK_RESET_BRIGHTNESS}" && \ reset_brightness } diff --git a/src/pm-action.in b/src/pm-action.in index ed537ca..3fe476b 100644 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -26,7 +26,7 @@ # The rule here? Simplicity. -help_options() +help() { echo "${0##*/} [options]" echo @@ -45,7 +45,7 @@ help_options() echo " --quirk-vbestate-restore" echo " --quirk-vga-mode3" echo " --quirk-none" - echo + exit 0 } if [ -n "$EUID" -a "$EUID" != "0" ]; then @@ -56,34 +56,21 @@ fi # Get the command line options while [ $# -gt 0 ] do - case "$1" in - --quirk-dpms-on) - export DISPLAY_QUIRK_DPMS_ON="true" ;; - --quirk-dpms-suspend) - export DISPLAY_QUIRK_DPMS_SUSPEND="true" ;; - --quirk-radeon-off) - export DISPLAY_QUIRK_RADEON_OFF="true" ;; - --quirk-reset-brightness) - export DISPLAY_QUIRK_RESET_BRIGHTNESS="true" ;; - --quirk-s3-bios) - export DISPLAY_QUIRK_S3_BIOS="true" ;; - --quirk-s3-mode) - export DISPLAY_QUIRK_S3_MODE="true" ;; - --quirk-vbe-post) - export DISPLAY_QUIRK_VBE_POST="true" ;; - --quirk-vbemode-restore) - export DISPLAY_QUIRK_VBEMODE_RESTORE="true" ;; - --quirk-vbestate-restore) - export DISPLAY_QUIRK_VBESTATE_RESTORE="true" ;; - --quirk-vga-mode3) - export DISPLAY_QUIRK_VGA_MODE_3="true" ;; - --quirk-none) - export DISPLAY_QUIRK_NONE="true" ;; - --help) - help_options - exit 0 ;; - *) - break ;; # terminate while loop + [ "${1##--}" = "$1" ] && break #if this matches, it is not an option! + [ "$1" = "--help" ] && help + case "${1##--quirk-}" in # just quirks, please + dpms-on) export QUIRK_DPMS_ON="true" ;; + dpms-suspend) export QUIRK_DPMS_SUSPEND="true" ;; + radeon-off) export QUIRK_RADEON_OFF="true" ;; + reset-brightness) export QUIRK_RESET_BRIGHTNESS="true" ;; + s3-bios) export QUIRK_S3_BIOS="true" ;; + s3-mode) export QUIRK_S3_MODE="true" ;; + vbe-post) export QUIRK_VBE_POST="true" ;; + vbemode-restore) export QUIRK_VBEMODE_RESTORE="true" ;; + vbestate-restore) export QUIRK_VBESTATE_RESTORE="true" ;; + vga-mode3) export QUIRK_VGA_MODE_3="true" ;; + none) export QUIRK_NONE="true" ;; + *) continue ;; esac shift done -- cgit v1.2.3 From dc1a31a76a26ff5258f02b0f533c53974c00e687 Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Sat, 1 Mar 2008 10:08:05 -0600 Subject: first pass at using run-hooks to get help info. The output from this will be ugly, if it even works. --- src/pm-action.in | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'src/pm-action.in') diff --git a/src/pm-action.in b/src/pm-action.in index 3fe476b..457149a 100644 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -26,25 +26,21 @@ # The rule here? Simplicity. +export PM_FUNCTIONS="@PM-UTILS-LIBDIR@/functions" +. "${PM_FUNCTIONS}" + 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 "Possible actions are:" + echo "Instead, any options you supply are passed on to the helper" + echo "progams that handle the details of power management." echo - echo " --quirk-dpms-on" - echo " --quirk-dpms-suspend" - echo " --quirk-radeon-off" - echo " --quirk-reset-brightness" - echo " --quirk-s3-bios" - echo " --quirk-s3-mode" - echo " --quirk-vbe-post" - echo " --quirk-vbemode-restore" - echo " --quirk-vbestate-restore" - echo " --quirk-vga-mode3" - echo " --quirk-none" + echo "Those options are:" + run_hooks sleep help exit 0 } @@ -75,9 +71,6 @@ do shift done -export PM_FUNCTIONS="@PM-UTILS-LIBDIR@/functions" -. "${PM_FUNCTIONS}" - ACTION="$(echo ${0##*pm-} |tr - _)" case "$ACTION" in -- cgit v1.2.3 From 8d5f23f720c121508bd61202cbd75c6d91a07f6d Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Sat, 1 Mar 2008 10:26:49 -0600 Subject: Moved video-specific option processing to 99video. --- pm/sleep.d/99video | 20 ++++++++++++++++++++ src/pm-action.in | 21 +++------------------ 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src/pm-action.in') diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video index 1aa6a99..e215e9d 100755 --- a/pm/sleep.d/99video +++ b/pm/sleep.d/99video @@ -9,6 +9,26 @@ . "${PM_FUNCTIONS}" +for opt in $PM_CMDLINE; do + [ "${opt#--quirk-}" = "$opt" ] && continue # not one we care about. + case "${1##--quirk-}" in # just quirks, please + dpms-on) QUIRK_DPMS_ON="true" ;; + dpms-suspend) QUIRK_DPMS_SUSPEND="true" ;; + radeon-off) QUIRK_RADEON_OFF="true" ;; + reset-brightness) QUIRK_RESET_BRIGHTNESS="true" ;; + s3-bios) QUIRK_S3_BIOS="true" ;; + s3-mode) QUIRK_S3_MODE="true" ;; + vbe-post) QUIRK_VBE_POST="true" ;; + vbemode-restore) QUIRK_VBEMODE_RESTORE="true" ;; + vbestate-restore) QUIRK_VBESTATE_RESTORE="true" ;; + vga-mode3) QUIRK_VGA_MODE_3="true" ;; + none) QUIRK_NONE="true" ;; + *) continue ;; + esac + shift +done + + reset_brightness() { for bl in /sys/class/backlight/* ; do diff --git a/src/pm-action.in b/src/pm-action.in index 457149a..9012802 100644 --- a/src/pm-action.in +++ b/src/pm-action.in @@ -29,6 +29,8 @@ export PM_FUNCTIONS="@PM-UTILS-LIBDIR@/functions" . "${PM_FUNCTIONS}" +# save the command line parameters for the hooks. +export PM_CMDLINE="$*" help() { echo "${0##*/} [options]" @@ -49,25 +51,10 @@ if [ -n "$EUID" -a "$EUID" != "0" ]; then exit 1 fi -# Get the command line options +# Save the command line options for the hooks while [ $# -gt 0 ] do - [ "${1##--}" = "$1" ] && break #if this matches, it is not an option! [ "$1" = "--help" ] && help - case "${1##--quirk-}" in # just quirks, please - dpms-on) export QUIRK_DPMS_ON="true" ;; - dpms-suspend) export QUIRK_DPMS_SUSPEND="true" ;; - radeon-off) export QUIRK_RADEON_OFF="true" ;; - reset-brightness) export QUIRK_RESET_BRIGHTNESS="true" ;; - s3-bios) export QUIRK_S3_BIOS="true" ;; - s3-mode) export QUIRK_S3_MODE="true" ;; - vbe-post) export QUIRK_VBE_POST="true" ;; - vbemode-restore) export QUIRK_VBEMODE_RESTORE="true" ;; - vbestate-restore) export QUIRK_VBESTATE_RESTORE="true" ;; - vga-mode3) export QUIRK_VGA_MODE_3="true" ;; - none) export QUIRK_NONE="true" ;; - *) continue ;; - esac shift done @@ -81,6 +68,4 @@ case "$ACTION" in exit 1 ;; esac -export PM_CMDLINE="$@" - pm_main "${ACTION}" "${REVERSE}" -- cgit v1.2.3 From 1fb77e994d7d1628c86324066693fd23d4abfb6c Mon Sep 17 00:00:00 2001 From: Victor Lowther Date: Sat, 1 Mar 2008 10:37:49 -0600 Subject: Cleaned up output for --help 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(-) (limited to 'src/pm-action.in') 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 } -- cgit v1.2.3