#!/bin/sh
#Barry Kauler 2005 www.puppylinux.com

VIDEOINFO="`cat /proc/pci | grep "VGA" | cut -f 2-4 -d ':'`"

BUTTONS="QUIT:10"
MSGCHANGE="NOTICE: The XF86_SVGA server is currently not installed."
CURRENTX="`readlink /usr/X11R6/bin/X`"
if [ "$CURRENTX" = "XF86_SVGA" ];then
 MSGCHANGE="NOTICE: The XF86_SVGA server is currently running. To change to the Xvesa
        X server, click \"Change_to_Xvesa\" button.
        To run the xf86config setup program for XF86_SVGA, click the
        \"Run_xf86config\" button.
        Both of these will require X to restart, so please close all other
        applications.
        There is also a GUI application called \"xvidtune\", for finetuning
        the display. Click \"Run_xvidtune\". Use with caution."
 BUTTONS="Run_xf86config:11,Run_xvidtune:14,Change_to_Xvesa:12,View_docs:15,QUIT:10"
else
 if [ -f /usr/X11R6/bin/XF86_SVGA ];then
  MSGCHANGE="NOTICE: The XF86_SVGA server is installed but currently not running.
        If you want to change to this server, click the \"Change_to_XF86_SVGA\"
        button.
        This will require X to restart, so please close all other applications."
  BUTTONS="Change_to_XF86_SVGA:13,View_docs:15,QUIT:10"
 fi
fi


SVGA336="      NV1, STG2000, RIVA 128, RIVA TNT, RIVA TNT2, RIVA ULTRA TNT2,
      RIVA VANTA, RIVA ULTRA VANTA, RIVA INTEGRATED, GeForce 256,
      GeForce DDR, Quadro, GeForce2 GTS, GeForce2 GTS (rev1),
      GeForce2 Ultra, Quadro 2 Pro, GeForce2 MX, GeForce2 MX DDR,
      Quadro 2 MXR, ET4000, ET4000W32, ET4000W32i, ET4000W32i_rev_b,
      ET4000W32i_rev_c, ET4000W32p, ET4000W32p_rev_a, ET4000W32p_rev_b,
      ET4000W32p_rev_c, ET4000W32p_rev_d, ET6000, ET6100, et3000, pvga1,
      wd90c00, wd90c10, wd90c30, wd90c24, wd90c31, wd90c33, gvga, r128, ati,
      sis86c201, sis86c202, sis86c205, sis86c215, sis86c225, sis5597,
      sis5598, sis6326, sis530, sis620, sis300, sis630, sis540, tvga8200lx,
      tvga8800cs, tvga8900b, tvga8900c, tvga8900cl, tvga8900d, tvga9000,
      tvga9000i, tvga9100b, tvga9200cxr, tgui9400cxi, tgui9420, tgui9420dgi,
      tgui9430dgi, tgui9440agi, cyber9320, tgui9660, tgui9680, tgui9682,
      tgui9685, cyber9382, cyber9385, cyber9388, cyber9397, cyber9520,
      cyber9525, 3dimage975, 3dimage985, cyber9397dvd, blade3d, cyberblade,
      clgd5420, clgd5422, clgd5424, clgd5426, clgd5428, clgd5429, clgd5430,
      clgd5434, clgd5436, clgd5446, clgd5480, clgd5462, clgd5464, clgd5465,
      clgd6205, clgd6215, clgd6225, clgd6235, clgd7541, clgd7542, clgd7543,
      clgd7548, clgd7555, clgd7556, ncr77c22, ncr77c22e, cpq_avga, mga2064w,
      mga1064sg, mga2164w, mga2164w AGP, mgag200, mgag100, mgag400, oti067,
      oti077, oti087, oti037c, al2101, ali2228, ali2301, ali2302, ali2308,
      ali2401, cl6410, cl6412, cl6420, cl6440, video7, ark1000vl, ark1000pv,
      ark2000pv, ark2000mt, mx, realtek, s3_savage, s3_virge, AP6422, AT24,
      AT3D, s3_svga, NM2070, NM2090, NM2093, NM2097, NM2160, NM2200,
      ct65520, ct65525, ct65530, ct65535, ct65540, ct65545, ct65546,
      ct65548, ct65550, ct65554, ct65555, ct68554, ct69000, ct64200,
      ct64300, mediagx, V1000, V2100, V2200, p9100, spc8110, i740, i740_pci,
      Voodoo Banshee, Voodoo3, smi, generic"


echo "$MSGCHANGE

Your PC has this video hardware:
$VIDEOINFO
However, Puppy cannot determine the chip model number. If you can determine
that your video chip is in this list then you will be able to use the
XF86_SVGA X server:

$SVGA336

However, this server may also work on recent video hardware that has
backwards-compatibility. For example, I got a VIA EPIA motherboard to
work, see this Forum thread: 
http://www.murga.org/%7Epuppy/viewtopic.php?t=1378

XF86_SVGA is a PupGet package, named \"xf86_svga-3.3.6\", that you can
download using the PupGet package manager, then reboot Puppy.

After rebooting, X may fail to start, dumping you back to the commandline.
In that case, do this:

Run the program \"xf86config\" from the commandline, and it takes you through
step by step, to create a new XF86Config file -- except at the final step it
wants to save to /etc/XF86Config -- just accept this and Puppy will move the
file to /etc/X11/ (where it is supposed to be).

NOTICE: Puppy 1.0.7 will prompt you to run xf86config if dropped back to the
        commandline, and gives some advice, similar to what is written here.

When it asks about which video hardware you have, you have the option of
bringing up a list and you choose what you think will work -- in my example
of the VIA EPIA board, the \"Trident CyberBlade (generic)\" works.
When it asks what video modes you want to support for each color-depth, get
rid of the \"640x480\", as the X server will default to that.

One thing that is very confusing is that there is no way to specify the default
color depth -- it is 8 bits, 256 colors. The docs state that an entry 
\"DefaultDepth 16\" can be used in XF86Config, however this particular X server
does not recognise that keyword and X will not start.
Solution, /usr/X11R6/bin/xwin, has inserted \"-bpp 16\" into this line:
  /usr/X11R6/bin/xinit /root/.xinitrc -- -bpp 16 > /tmp/xerrs.log 2>&1
Change that to \"24\" if you need greater color depth.

WHAT TO DO IF XF86_SVGA WILL NOT WORK!
You can drop back to the Xvesa Kdrive X server by typing this:
# ln -sf Xvesa /usr/X11R6/bin/X
# xwin

Note also that the PupGet package has \"xvidetune\", and docs are in
/usr/share/xf86_svga.txt, xf86config.htm, xvidtune.htm and Xserver.htm."  > /tmp/svga336msg.txt


while [ 1 ];do
xmessage -center -title "XF86_SVGA video Wizard" -buttons "$BUTTONS" -file /tmp/svga336msg.txt

RETVAL=$?
if [ $RETVAL -lt 11 ];then
 exit
fi

if [ $RETVAL -eq 11 ];then #run xf86config
 rxvt -bg yellow -e /usr/X11R6/bin/xf86config
 sync
 exec restartwm #no w.m. param, defaults to current.
fi
if [ $RETVAL -eq 12 ];then #change to Xvesa
 ln -sf Xvesa /usr/X11R6/bin/X
 sync
 exec restartwm
fi
if [ $RETVAL -eq 13 ];then #change to XF86_SVGA
 ln -s XF86_SVGA /usr/X11R6/bin/X
 xmessage -center -bg orange "X is now going to die. At the commandline, type \"xf86config\""
 sync
 exec killall X
fi
if [ $RETVAL -eq 14 ];then #run xvidtune
 xvidtune > /tmp/xvidtunedump.txt 2>&1
 xmessage -center -bg green -title "Output from xvidtune" -file /tmp/xvidtunedump.txt
 exit
fi
if [ $RETVAL -eq 15 ];then #view docs
 xmessage -center -bg "#ffc0c0" -title "View XG86_SVGA docs" -buttons "xf86_svga:11,xf86config:12,xvidtune:13,Xserver:14,QUIT:10" "Choose which docs to view..."
 case $? in
 11)
  defaulthandler file:///usr/share/doc/xf86_svga.txt &
  ;;
 12)
  defaultbrowser file:///usr/share/doc/xf86config.htm &
  ;;
 13)
  defaultbrowser file:///usr/share/doc/xvidtune.htm &
  ;;
 14)
  defaultbrowser file:///usr/share/doc/Xserver.htm &
  ;;
 *)
  echo "continue loop"
  ;;
 esac
fi

done

###END###
