#!/bin/bash
#
# Stefan Seyfried, SUSE Linux Products GmbH, 2006
# mostly taken from the powersave project

#############################################################################
# if the system is configured for 855resolution, we first patch the BIOS
# to avoid that the X server crashes after switching back to X

. /usr/lib/pm-utils/functions

patch-bios()
{
	if [ -e /etc/sysconfig/videobios ]; then
		. /etc/sysconfig/videobios
		if [ "$VIDEOBIOS_PATCH" = "yes" ]; then
			BIOS_INIT="/etc/init.d/boot.videobios"
			echo "patching video bios..."
			[ -x $BIOS_INIT ] && $BIOS_INIT start >/dev/null 2>&1
		fi
	fi
}

case $1 in
	hibernate)
		savestate vbios_console $(/bin/fgconsole )
		chvt 1
		;;
	thaw)
		patch-bios
		chvt $(restorestate vbios_console)
		;;
esac

exit 0
