#!/bin/sh
#
# This script uses the "scan" mode from SVGATextMode to construct a list of all 
# modes allowed for your setup, and then displays a "dialog" box which lets
# you select a mode, and program it.
#
# Created by Wouter Gadeyne
# 
#

STM=/usr/sbin/SVGATextMode

ModeDB=`$STM -s | awk '{ printf("%s \"%10s %8s %5s %18s\" "),$1,$3,$5,$7,$9}' `

MODE=`eval "dialog --title 'SVGATextMode: select a TextMode' \
                   --menu 'Mode             Clock     screen  font    Refresh       ' 24 80 17 $ModeDB" \
3>&1 1>&2 2>&3 `


#
# Let SVGATextMode process the mode, and show the parameters
# Ask if this mode should be programmed
#

MODEDATA=`$STM -n $MODE`

dialog --title "SVGATextMode: program \"$MODE\" mode?" \
       --yesno "$MODEDATA" 7 70

#
# Now program the mode, if the answer was "yes"
#

if [ $? = 0 ]; then
	$STM $MODE
fi
