1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet
# Vbetool scriptlet requires Matt J Garrett's vbetool package to be useful.
# http://www.srcf.ucam.org/~mjg59/vbetool/
#
# This scriptlet Copyright (C) Cameron Patrick, 2005, and may be
# used under the same terms as hibernate-script itself.
AddConfigHandler VbetoolOptions
AddConfigHelp "EnableVbetool <boolean>" "Save and restore video state using vbetool before and after suspending."
AddConfigHelp "RestoreVbeStateFrom <filename>" "If set, will restore the VBE state with the data stored in <filename>. Use this if your card requires you to restore it with a state captured at boot (from single user mode, run \"vbetool vbestate save > /var/lib/vbetool/vbestate\"). If this option is not set, the state is saved just before suspending."
AddConfigHelp "VbetoolPost <boolean>" "If yes, will call the video BIOS's POST routine to reinitialise the video card. Some cards need this to turn on the backlight back and be useful after resuming. Other video cards will hang if you attempt to POST them. Try it with yours and see."
# hopefully this is a good choice and nothing else uses it :-/
VBETOOL_VT=61
VBETOOL_ENABLED=
VBETOOL_POST=
VBETOOL_SAVED_STATE=
VbetoolSaveState() {
# if we're switched off, don't do nuffin
[ x"$VBETOOL_ENABLED" = "x1" ] || return 0
# Make sure we have a vbetool.
if ! command -v vbetool > /dev/null 2>&1 ; then
VBETOOL_ENABLED=0
vecho 1 "'vbetool' utility not found. Vbetool disabled."
return 0
fi
# If we already have a saved state, don't bother saving it now.
[ -n "$VBETOOL_SAVED_STATE" ] && return 0
# save our previous VT and switch to a new one
VBETOOL_ORIG_VT=`fgconsole 2>/dev/null` || VBETOOL_ORIG_VT=1
chvt $VBETOOL_VT
TERM=linux tput clear
VBETOOL_FILE=`mktemp /tmp/tmp.hibernate.XXXXXX`
# save the vbe state
vbetool vbestate save > $VBETOOL_FILE || return 1
return 0
}
VbetoolRestoreState() {
# if we're switched off, don't do nuffin
[ x"$VBETOOL_ENABLED" = "x1" ] || return 0
# POST if we're asked to
[ x"$VBETOOL_POST" = "x1" ] && vbetool post
# Restore a saved state.
if [ -n "$VBETOOL_SAVED_STATE" ] ; then
vbetool vbestate restore < $VBETOOL_SAVED_STATE
elif [ -n "$VBETOOL_FILE" ] ; then
vbetool vbestate restore < $VBETOOL_FILE
rm -f $VBETOOL_FILE
fi
# see if we can power on the display too
vbetool dpms on
# change back to our original VT
chvt $VBETOOL_ORIG_VT
}
VbetoolOptions() {
case $1 in
enablevbetool)
BoolIsOn "$1" "$2" && VBETOOL_ENABLED=1 || return 0
;;
vbetoolpost)
BoolIsOn "$1" "$2" && VBETOOL_POST=1 || return 0
;;
restorevbestatefrom)
VBETOOL_SAVED_STATE=$2
if ! [ -r "$VBETOOL_SAVED_STATE" ] ; then
vecho 0 "$EXE: vbetool: Saved state file does not exist ($VBETOOL_SAVED_STATE)"
vecho 0 "$EXE: vbetool: Saving state on suspend instead."
VBETOOL_SAVED_STATE=
return 0
fi
;;
*)
return 1
esac
if [ -z "$VBETOOL_HOOKED" ] ; then
AddSuspendHook 97 VbetoolSaveState
AddResumeHook 97 VbetoolRestoreState
VBETOOL_HOOKED=1
fi
return 0
}
|