summaryrefslogtreecommitdiff
path: root/pm
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-01-28 20:37:02 +0000
committerRichard Hughes <richard@hughsie.com>2008-01-28 20:37:02 +0000
commit6c4f5b58e6ce915c96f29935f2f719f39586f378 (patch)
tree9ef72364b509bc7414071c79ecd5184571de991b /pm
parent9e058adb8718d3682c8a5b861e3f8796e4e3bbdb (diff)
Make condition checking in (20|99)video POSIX compliant, and modify
vbe() and radeon() to only check for the existence of (vbe|radeon)tool once per hook invocation instead of once per function invocation.
Diffstat (limited to 'pm')
-rwxr-xr-xpm/sleep.d/20video46
-rwxr-xr-xpm/sleep.d/99video43
2 files changed, 38 insertions, 51 deletions
diff --git a/pm/sleep.d/20video b/pm/sleep.d/20video
index e88eb75..41e79ad 100755
--- a/pm/sleep.d/20video
+++ b/pm/sleep.d/20video
@@ -9,53 +9,47 @@
. /usr/lib/pm-utils/functions
-vbetool=$(type -p vbetool)
-vbe() {
- if [ -z "$vbetool" ]; then
- echo "vbetool not found" 1>&2
- return 1
- fi
- $vbetool "$@"
-}
+if type vbetool |grep -q "not found" ; then
+ vbe() { echo "vbetool not found" 1>&2; return 1; }
+else
+ vbe() { vbetool "$@"; }
+fi
-radeontool=$(type -p radeontool)
-radeon() {
- if [ -z "$radeontool" ]; then
- echo "radeontool not found" 1>&2
- return 1
- fi
- $radeontool "$@"
-}
+if type radeontool |grep -q "not found" ; then
+ radeon() { echo "radeontool not found" 1>&2; return 1; }
+else
+ radeon() { radeontool "$@"; }
+fi
suspend_video()
{
# 0=nothing, 1=s3_bios, 2=s3_mode, 3=both
- if [ "${DISPLAY_QUIRK_S3_BIOS}" == "true" -a \
- "${DISPLAY_QUIRK_S3_MODE}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_S3_BIOS}" = "true" -a \
+ "${DISPLAY_QUIRK_S3_MODE}" = "true" ]; then
sysctl -w kernel.acpi_video_flags=3
- elif [ "${DISPLAY_QUIRK_S3_BIOS}" == "true" ]; then
+ elif [ "${DISPLAY_QUIRK_S3_BIOS}" = "true" ]; then
sysctl -w kernel.acpi_video_flags=1
- elif [ "${DISPLAY_QUIRK_S3_MODE}" == "true" ]; then
+ elif [ "${DISPLAY_QUIRK_S3_MODE}" = "true" ]; then
sysctl -w kernel.acpi_video_flags=2
else
sysctl -w kernel.acpi_video_flags=0
fi
# We might need to do one or many of these quirks
- if [ "${DISPLAY_QUIRK_RADEON_OFF}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_RADEON_OFF}" = "true" ]; then
radeon dac off
radeon light off
fi
- if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" = "true" ]; then
vbe vbestate save > /var/run/vbestate
fi
- if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" = "true" ]; then
vbe vbemode get > /var/run/vbemode
fi
- if [ "${DISPLAY_QUIRK_VGA_MODE_3}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_VGA_MODE_3}" = "true" ]; then
vbe vbemode set 3
fi
- if [ "${DISPLAY_QUIRK_DPMS_SUSPEND}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_DPMS_SUSPEND}" = "true" ]; then
vbe dpms suspend
fi
}
@@ -66,7 +60,7 @@ case "$1" in
suspend_video
;;
hibernate)
- if [ "x$HIBERNATE_RESUME_POST_VIDEO" == "xyes" ]; then
+ if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
suspend_video
fi
;;
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index 882cae3..9695e8b 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -12,7 +12,6 @@
reset_brightness() {
for bl in /sys/class/backlight/* ; do
- [ -d $bl ] || continue
[ -f $bl/brightness ] || continue
BR=$(cat $bl/brightness)
echo 0 > $bl/brightness
@@ -20,45 +19,39 @@ reset_brightness() {
done
}
-vbetool=$(type -p vbetool)
-vbe() {
- if [ -z "$vbetool" ]; then
- echo "vbetool not found" 1>&2
- return 1
- fi
- $vbetool "$@"
-}
+if type vbetool |grep -q "not found"; then
+ vbe() { echo "vbetool not installed!" 1>&2; return 1; }
+else
+ vbe() { vbetool "$@"; }
+fi
-radeontool=$(type -p radeontool)
-radeon() {
- if [ -z "$radeontool" ]; then
- echo "radeontool not found" 1>&2
- return 1
- fi
- $radeontool "$@"
-}
+if type radeontool |grep -q "not found"; then
+ radeon() { echo "radeontool not found" 1>&2; return 1; }
+else
+ radeon() { radeontool "$@"; }
+fi
resume_video()
{
- if [ "${DISPLAY_QUIRK_RADEON_OFF}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_RADEON_OFF}" = "true" ]; then
radeon dac on
radeon light on
fi
# We might need to do one or many of these quirks
- if [ "${DISPLAY_QUIRK_VBE_POST}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_VBE_POST}" = "true" ]; then
vbe post
usleep 100000
fi
- if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" = "true" ]; then
vbe vbestate restore < /var/run/vbestate
fi
- if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" == "true" ]; then
- vbe vbemode set `cat /var/run/vbemode`
+ if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" = "true" ]; then
+ vbe vbemode set $(cat /var/run/vbemode)
fi
- if [ "${DISPLAY_QUIRK_DPMS_ON}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_DPMS_ON}" = "true" ]; then
vbe dpms on
fi
- if [ "${DISPLAY_QUIRK_RESET_BRIGHTNESS}" == "true" ]; then
+ if [ "${DISPLAY_QUIRK_RESET_BRIGHTNESS}" = "true" ]; then
reset_brightness
fi
}
@@ -69,7 +62,7 @@ case "$1" in
resume_video
;;
thaw)
- if [ "x$HIBERNATE_RESUME_POST_VIDEO" == "xyes" ]; then
+ if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
resume_video
fi
;;