diff options
-rw-r--r-- | pm/functions.in | 15 | ||||
-rw-r--r-- | pm/pm-functions.in | 2 | ||||
-rwxr-xr-x | pm/sleep.d/90clock | 2 | ||||
-rwxr-xr-x | pm/sleep.d/98smart-kernel-video | 26 | ||||
-rwxr-xr-x | pm/sleep.d/99video | 8 |
5 files changed, 23 insertions, 30 deletions
diff --git a/pm/functions.in b/pm/functions.in index bd0705c..0aba5ea 100644 --- a/pm/functions.in +++ b/pm/functions.in @@ -3,8 +3,20 @@ # Common functionality for the hooks. +# If a variable is set to true, yes, 1, or is simply set with no value, +# return 0, otherwise return 1. +is_set() +{ + case ${1-UNSET} in + true|yes|TRUE|YES|on|ON|1'') return 0;; + false|FALSE|no|NO|off|OFF|0|UNSET) return 1;; + *) return 2;; + esac +} + # for great debugging! -[ "${PM_DEBUG}" = "true" ] && set -x +is_set "${PM_DEBUG}" && set -x + # try to take the lock. Fail if we cannot get it. try_lock() @@ -246,3 +258,4 @@ dbus_send () { command dbus-send "$@" 2>/dev/null || return $NA } + diff --git a/pm/pm-functions.in b/pm/pm-functions.in index 8ba975c..67910ea 100644 --- a/pm/pm-functions.in +++ b/pm/pm-functions.in @@ -89,7 +89,7 @@ fi # We do it this way because 'echo -n' is not posix. log() { - [ $LOGGING ] || return 0; + is_set "$LOGGING" || return 0; local fmt='%s\n' [ "$1" = "-n" ] && { fmt='%s'; shift; } printf "$fmt" "$*" diff --git a/pm/sleep.d/90clock b/pm/sleep.d/90clock index d961e34..b8ade29 100755 --- a/pm/sleep.d/90clock +++ b/pm/sleep.d/90clock @@ -14,7 +14,7 @@ resume_clock() /sbin/hwclock --hctosys >/dev/null 2>&1 0<&1 } -[ "$NEED_CLOCK_SYNC" ] || exit $NA +is_set "$NEED_CLOCK_SYNC" || exit $NA case "$1" in hibernate|suspend) suspend_clock ;; diff --git a/pm/sleep.d/98smart-kernel-video b/pm/sleep.d/98smart-kernel-video index 911896c..11b5490 100755 --- a/pm/sleep.d/98smart-kernel-video +++ b/pm/sleep.d/98smart-kernel-video @@ -32,7 +32,7 @@ have_kms() { # if we are running with a KMS-enabled video driver, we should not # attempt to run any quirks - [ -d /sys/class/drm/card0/device/graphics/fb0 ] || return 1 + grep -q -E '(noveau|drm)fb' /proc/fb || return 1 remove_all_video_quirks add_parameters --quirk-no-chvt } @@ -44,6 +44,7 @@ have_nvidia() # suspend/resume in a quirk-free manner. [ -d /sys/module/nvidia ] || return 1 remove_all_video_quirks + add_parameters --quirk-no-chvt } have_fglrx() @@ -53,30 +54,9 @@ have_fglrx() remove_all_video_quirks } -have_smart_intel() -{ - # currently, intel kernel modesetting is not quite smart enough - # we still need acpi s3 kernel modesetting hooks, so don't remove those - # options if they were passed. - [ -d /sys/module/i915 ] || return 1 - local kernel_rev="$(uname -r |awk -F '[_-]' '{print $1}')" - [ "$kernel_rev" \> "2.6.26" -o "$kernel_rev" = "2.6.26" ] || return 1 - remove_parameters --quirk-dpms-on \ - --quirk-dpms-suspend \ - --quirk-vbe-post \ - --quirk-vbe-post \ - --quirk-vga-mode3 \ - --quirk-vbemode-restore \ - --quirk-vbestate-restore \ - --quirk-reset-brightness \ - --quirk-radeon-off \ - --quirk-no-fb \ - --quirk-pci-save -} - smart_kernel_video() { - have_kms || have_nvidia || have_fglrx || have_smart_intel || return $NA + have_kms || have_nvidia || have_fglrx || return $NA } case $1 in diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video index 23e56ef..957cbc2 100755 --- a/pm/sleep.d/99video +++ b/pm/sleep.d/99video @@ -85,7 +85,7 @@ resume_fbcon() maybe_chvt() { - [ "$QUIRK_NO_CHVT" = "true" ] && return + is_set "$QUIRK_NO_CHVT" && return fgconsole |savestate console chvt 63 } @@ -98,7 +98,7 @@ maybe_deallocvt() } # Some tiny helper functions for quirk handling -quirk() { [ "$1" = "true" ] && [ -z $QUIRK_NONE ]; } +quirk() { is_set "$1" && [ -z $QUIRK_NONE ]; } # save/restore vbe state vbe_savestate() { vbe vbestate save |savestate vbestate; } @@ -204,13 +204,13 @@ help() { case "$1" in suspend) maybe_chvt; suspend_video ;; hibernate) maybe_chvt - if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then + if is_set "$HIBERNATE_RESUME_POST_VIDEO"; then suspend_video fi ;; resume) resume_video; maybe_deallocvt;; thaw) - if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then + if is_set "${HIBERNATE_RESUME_POST_VIDEO}"; then resume_video fi maybe_deallocvt |