#!/bin/bash
#
# vbestate_save - part of the powersave package. Stefan Seyfried 2005
# saves VBE state before 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!
#
# There are some sources that state that VBE state should only be saved
# once - e.g. during bootup and then be reused on every resume, others
# say it is better to save it again before every suspend.
#
# To save it at bootup, copy this script script, remove the chvt 1, save
# it under a different name and call it from /etc/init.d/boot.local
# Make a second copy with only the chvt 1 part, save it in the powersave
# scripts dir /usr/lib/powersave/scripts and put its name into the
# EVENT_GLOBAL_SUSPEND2RAM event before do_suspend2ram.
#
# To save it before every suspend, just copy this script unaltered to
# /usr/lib/powersave/scripts, make sure it is executable and put its
# name "vbestate_save" into the EVENT_GLOBAL_SUSPEND2RAM event
# before do_suspend2ram.
#
# this needs vbetool.rpm installed, of course.

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

S3STATEDIR=/root/s3state
mkdir -p $S3STATEDIR
cd $S3STATEDIR
#### end of common part ####

###### chvt 1 part #########
fgconsole > fgconsole.state
chvt 1
###### end of chvt part ####
###### vbestate part #######
vbetool vbestate save > vbe.state
###### end of vbestate #####

#### common part############
$SCRIPT_RETURN $EV_ID 0 "$MYNAME finished"
EXIT 0
#### end of common part ####
