#!/bin/bash
#
# vbestate_restore - part of the powersave package. Stefan Seyfried 2005
# restore VBE state after suspend. This can be used to get your graphics
# card going after suspend to RAM. Note that this is an ugly hack and not
# recommended unless you know what you are doing and what this can do to
# your hardware and your data!
#
# VBE state has already have to be saved obviously, either at bootup or
# before suspend. Read the comments in vbestate_save for more information. 
#
# Copy this script into /usr/lib/powersave/scripts, make sure it is
# executable, put its name (vbestate_restore) into the
# EVENT_GLOBAL_RESUME_SUSPEND2RAM event as the first event.
# this needs vbetool.rpm installed, of course.

# look into the example_event_script for an explanation
. ${0%/*}/helper_functions # `dirname $0`/helper_functions

S3STATEDIR=/root/s3state
mkdir -p $S3STATEDIR
cd $S3STATEDIR

# post the card. This may not be necessary, try it out.
vbetool post

# restore the VBE state of the card.
vbetool vbestate restore < vbe.state

# change to the console we were on before suspend
read CONS < fgconsole.state
chvt $CONS

$SCRIPT_RETURN $EV_ID 0 "$MYNAME finished"
EXIT 0
