home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / bin / y2xr < prev    next >
Encoding:
Text File  |  2000-03-30  |  4.0 KB  |  185 lines

  1. #!/bin/sh
  2. # Copyright (c) 1996 S.u.S.E. GmbH Fuerth, Germany.  All rights reserved.
  3. #
  4. # Author: Marcus Schaefer <sax@suse.de>, 1999
  5. #
  6. # this script is used to generate a generic configuration 
  7. # using isax which is used to query some information about the
  8. # X-Server which comes with this config file
  9. #
  10. # The result is a list of available resoultions per colordepth
  11. # The script needs the following parameter as input:
  12. # - list of colordepth, for example -c 8,16,24,32
  13. # - basename of X-Server, for example -s svga
  14. # - maximum allowed memory in Kbyte, for example -m 4096
  15. #
  16. set +o posix     # We want bash features
  17. set -m           # Enable job monitor enable
  18. set -b           # Notify job immediately
  19.  
  20.  
  21. function usage() {
  22.  echo "Linux ISaX Version 1.2 startup level (1) (02/02/2000)"
  23.  echo "(C) Copyright 1999 - SuSE GmbH"
  24.  echo 
  25.  echo "usage: xr [ options ]"
  26.  echo "options:"
  27.  echo "[ -h | --help ]"
  28.  echo "  show this message and exit"
  29.  echo "[ -c | --colors ]"
  30.  echo "  list of supported color bits"
  31.  echo "  you may specify a comma separated list"
  32.  echo "[ -s | --server ]"
  33.  echo "  basename of X-Server"
  34. }
  35.  
  36. # initialize...
  37. # --------------
  38. ISAX="/usr/X11R6/bin/isax"
  39. XDIR="/usr/X11R6/bin"
  40. CONF="/tmp/config"
  41. PLOG="/var/X11R6/sax/bin/ParseXerr"
  42.  
  43. RESOLUTION="640x480:1 800x600:2 1024x768:3 1152x864:4 \
  44.             1280x960:5 1280x1024:6 1600x1200:7";
  45.  
  46. SERVER="";
  47. COLORS="";
  48.  
  49. # get options
  50. # -------------
  51. TEMP=`getopt -o c:s:h --long colors:,server:,help \
  52.      -n 'SaX' -- "$@"`
  53.  
  54. if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  55. eval set -- "$TEMP"
  56.  
  57. while true ; do
  58.  case "$1" in
  59.   -s|--server)
  60.     SERVER=$2; shift 2 ;;
  61.  
  62.   -c|--colors)
  63.     COLORS=$2; shift 2 ;;
  64.  
  65.   -h|--help)
  66.     usage; exit 0 ;;
  67.  
  68.   --)
  69.    shift ; break ;;
  70.  
  71.   *)
  72.    echo "ISaX: Internal error!" ; exit 1 ;;
  73.  esac
  74. done
  75.  
  76. # prove on root... 
  77. #------------------
  78. if [ ! $UID = "0" ];then
  79.  echo "sorry: only root can do this" 
  80.  exit 1
  81. fi
  82.  
  83. # prove files and parameters...
  84. # ------------------------------
  85. if [ -z "$SERVER" ]; then
  86.  echo "sorry: no server name specified"
  87.  exit 1
  88. fi
  89. if [ -z "$COLORS" ]; then
  90.  echo "sorry: no color list specified"
  91.  exit 1
  92. fi
  93. if [ ! -f "$PLOG" ];then
  94.  echo "sorry no parser found"
  95.  exit 1
  96. fi
  97.  
  98.  
  99. # get Display...
  100. #---------------
  101. if [ -z "$DISPLAY" ]; then
  102.  export DISPLAY=:0
  103.  DISP=:0
  104.  export DISPLAY=:0 
  105. else 
  106.  DISP=`echo $DISPLAY | cut -f2 -d: | cut -c1`
  107.  DISP=`expr $DISP + 1`  
  108.  export DISPLAY=:$DISP
  109. fi
  110.  
  111.  
  112. # create the isax variable file for generic startup
  113. # --------------------------------------------------
  114. rm -f $CONF 2>/dev/null
  115. if [ -f $CONF ];then
  116.  echo "$CONF still exists... abort"
  117.  exit 1
  118. fi
  119. SERVER=`echo $SERVER | tr '[:lower:]' '[:upper:]'` 
  120. for i in `ls -1 $XDIR/X*`;do 
  121.  BASE=`basename $i | grep -Ei $SERVER`
  122.  if [ ! -z "$BASE" ];then
  123.   break
  124.  fi
  125. done
  126.  
  127. echo "SERVER      = \"$SERVER\""                     >   $CONF
  128. echo "LANGUAGE    = \"de\""                          >>  $CONF
  129. echo "COLORDEPTH  = \"8\""                           >>  $CONF
  130. echo "CONFIG      = \"$CONF\""                       >>  $CONF
  131. echo "KBDPROT     = \"Standard\""                    >>  $CONF
  132. echo "XKBRULES    = \"xfree86\""                     >>  $CONF
  133. echo "SYMBOLS     = \"en_US(pc104)+de(nodeadkeys)\"" >>  $CONF
  134. echo "GEOMETRY    = \"pc(pc104)\""                   >>  $CONF
  135. echo "CARDOPTS    = \"noaccel\""                     >>  $CONF
  136.  
  137. $ISAX -f $CONF
  138.  
  139. # run the server... 
  140. #-------------------
  141. STUFF=`$XDIR/$BASE -probeonly -xf86config $CONF :$DISP 2>&1 \
  142.        | $PLOG | grep -i videoram | cut -f2 -d:`
  143. STUFF=`echo $STUFF | tr -d [a-zA-Z]`
  144.  
  145. echo "\$["
  146.  
  147. COLORS=`echo $COLORS | tr "," " "`
  148. first="1"
  149. for c in $COLORS;do
  150.  list=""
  151.  for r in $RESOLUTION;do
  152.   X=`echo $r | cut -f1 -dx`
  153.   Y=`echo $r | cut -f2 -dx | cut -f1 -d:`
  154.   N=`echo $r | cut -f2 -dx | cut -f2 -d:`
  155.  
  156.   MEM=`expr $X \* $Y \* $c \/ 8` 
  157.   MEM=`expr $MEM \/ 1024`
  158.  
  159.   if [ "$MEM" -le "$STUFF" ];then
  160.    if [ -z "$list" ];then
  161.     list="$N"
  162.    else
  163.     list="$list,$N"
  164.    fi
  165.   fi
  166.  done
  167.  
  168.  if [ $first = "1" ];then
  169.      echo "$c:[$list]"
  170.      first="2";
  171.  else
  172.      echo ",$c:[$list]";
  173.  fi
  174.  
  175. done
  176. echo "]"
  177.  
  178. # clean up...
  179. # -------------
  180. rm -f $CONF 2>/dev/null
  181.  
  182. exit 0
  183.  
  184.