home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # Copyright (c) 1996 S.u.S.E. GmbH Fuerth, Germany. All rights reserved.
- #
- # Author: Marcus Schaefer <sax@suse.de>, 1999
- #
- # this script is used to generate a generic configuration
- # using isax which is used to query some information about the
- # X-Server which comes with this config file
- #
- # The result is a list of available resoultions per colordepth
- # The script needs the following parameter as input:
- #
- # - list of colordepth, for example -c 8,16,24,32
- # - basename of X-Server, for example -s svga
- # - maximum allowed memory in Kbyte, for example -m 4096
- #
- set +o posix # We want bash features
- set -m # Enable job monitor enable
- set -b # Notify job immediately
-
-
- function usage() {
- echo "Linux ISaX Version 1.2 startup level (1) (02/02/2000)"
- echo "(C) Copyright 1999 - SuSE GmbH"
- echo
- echo "usage: xr [ options ]"
- echo "options:"
- echo "[ -h | --help ]"
- echo " show this message and exit"
- echo "[ -c | --colors ]"
- echo " list of supported color bits"
- echo " you may specify a comma separated list"
- echo "[ -s | --server ]"
- echo " basename of X-Server"
- }
-
- # initialize...
- # --------------
- ISAX="/usr/X11R6/bin/isax"
- XDIR="/usr/X11R6/bin"
- CONF="/tmp/config"
- PLOG="/var/X11R6/sax/bin/ParseXerr"
-
- RESOLUTION="640x480:1 800x600:2 1024x768:3 1152x864:4 \
- 1280x960:5 1280x1024:6 1600x1200:7";
-
- SERVER="";
- COLORS="";
-
- # get options
- # -------------
- TEMP=`getopt -o c:s:h --long colors:,server:,help \
- -n 'SaX' -- "$@"`
-
- if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
- eval set -- "$TEMP"
-
- while true ; do
- case "$1" in
- -s|--server)
- SERVER=$2; shift 2 ;;
-
- -c|--colors)
- COLORS=$2; shift 2 ;;
-
- -h|--help)
- usage; exit 0 ;;
-
- --)
- shift ; break ;;
-
- *)
- echo "ISaX: Internal error!" ; exit 1 ;;
- esac
- done
-
- # prove on root...
- #------------------
- if [ ! $UID = "0" ];then
- echo "sorry: only root can do this"
- exit 1
- fi
-
- # prove files and parameters...
- # ------------------------------
- if [ -z "$SERVER" ]; then
- echo "sorry: no server name specified"
- exit 1
- fi
- if [ -z "$COLORS" ]; then
- echo "sorry: no color list specified"
- exit 1
- fi
- if [ ! -f "$PLOG" ];then
- echo "sorry no parser found"
- exit 1
- fi
-
-
- # get Display...
- #---------------
- if [ -z "$DISPLAY" ]; then
- export DISPLAY=:0
- DISP=:0
- export DISPLAY=:0
- else
- DISP=`echo $DISPLAY | cut -f2 -d: | cut -c1`
- DISP=`expr $DISP + 1`
- export DISPLAY=:$DISP
- fi
-
-
- # create the isax variable file for generic startup
- # --------------------------------------------------
- rm -f $CONF 2>/dev/null
- if [ -f $CONF ];then
- echo "$CONF still exists... abort"
- exit 1
- fi
- SERVER=`echo $SERVER | tr '[:lower:]' '[:upper:]'`
- for i in `ls -1 $XDIR/X*`;do
- BASE=`basename $i | grep -Ei $SERVER`
- if [ ! -z "$BASE" ];then
- break
- fi
- done
-
- echo "SERVER = \"$SERVER\"" > $CONF
- echo "LANGUAGE = \"de\"" >> $CONF
- echo "COLORDEPTH = \"8\"" >> $CONF
- echo "CONFIG = \"$CONF\"" >> $CONF
- echo "KBDPROT = \"Standard\"" >> $CONF
- echo "XKBRULES = \"xfree86\"" >> $CONF
- echo "SYMBOLS = \"en_US(pc104)+de(nodeadkeys)\"" >> $CONF
- echo "GEOMETRY = \"pc(pc104)\"" >> $CONF
- echo "CARDOPTS = \"noaccel\"" >> $CONF
-
- $ISAX -f $CONF
-
- # run the server...
- #-------------------
- STUFF=`$XDIR/$BASE -probeonly -xf86config $CONF :$DISP 2>&1 \
- | $PLOG | grep -i videoram | cut -f2 -d:`
- STUFF=`echo $STUFF | tr -d [a-zA-Z]`
-
- echo "\$["
-
- COLORS=`echo $COLORS | tr "," " "`
- first="1"
- for c in $COLORS;do
- list=""
- for r in $RESOLUTION;do
- X=`echo $r | cut -f1 -dx`
- Y=`echo $r | cut -f2 -dx | cut -f1 -d:`
- N=`echo $r | cut -f2 -dx | cut -f2 -d:`
-
- MEM=`expr $X \* $Y \* $c \/ 8`
- MEM=`expr $MEM \/ 1024`
-
- if [ "$MEM" -le "$STUFF" ];then
- if [ -z "$list" ];then
- list="$N"
- else
- list="$list,$N"
- fi
- fi
- done
-
- if [ $first = "1" ];then
- echo "$c:[$list]"
- first="2";
- else
- echo ",$c:[$list]";
- fi
-
- done
- echo "]"
-
- # clean up...
- # -------------
- rm -f $CONF 2>/dev/null
-
- exit 0
-
-