home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / sbin / xorgwizard < prev    next >
Encoding:
Text File  |  2006-04-27  |  33.3 KB  |  897 lines

  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler 2006 www.puppylinux.com
  3.  
  4. PSFND="`ps`"
  5. CURRENTX="`readlink /usr/X11R6/bin/X`"
  6.  
  7. #v2.0.0
  8. choosemousefunc() {
  9.  #assume kernel drivers already loaded. rc.local0 reliably detects usb mouse and loads driver,
  10.  #ps/2 and serial drivers builtin to kernel.
  11.  dialog --no-cancel --menu "Please choose mouse type...\n(You can identify type by plug shape)\nUse UP/DOWN ARROW keys, ENTER key to finish" 0 0 0 "ps/2" "(little 8mm round green plug)" "usb" "(little 11x4mm flat plug)" "serial" "(big 15x9mm DB9 or DB25 plug)" 2> /tmp/testmsx
  12.  MOUSETYPE="`cat /tmp/testmsx`"
  13.  MOUSEDEV="psaux"
  14.  [ "$MOUSETYPE" = "usb" ] && MOUSEDEV="input/mice"
  15.  if [ "$MOUSETYPE" = "serial" ];then
  16.   dialog --no-cancel --menu "Serial port mouse plugged into...\nUse UP/DOWN ARROW keys, ENTER key to finish" 0 0 0 ttyS0 "COM1 (most likely)" ttyS1 COM2 ttyS2 COM3 ttyS3 COM4 2> /tmp/testmsx
  17.   MOUSEDEV="`cat /tmp/testmsx`"
  18.  fi
  19.  ln -sf /dev/$MOUSEDEV /dev/mouse
  20.  echo -n "$MOUSEDEV" > /etc/mousedevice #note, rc.local0 will read this on next boot.
  21.  #fix mouse protocol for Xorg...
  22.  if [ -f /etc/X11/xorg.conf ];then
  23.     case `cat /etc/mousedevice | cut -b 1-4` in
  24.      "inpu") #"input/mice", usb
  25.       cat /etc/X11/xorg.conf | sed -e 's/\W\+Option\W\+"Protocol"\W\+"\w\+\W\+#mouse0protocol/    Option        "Protocol" "IMPS\/2" #mouse0protocol/g' > /tmp/xorg.conf.tmp2
  26.       ;;
  27.      "ttyS") #ttyS0,1,2,3, serial
  28.       cat /etc/X11/xorg.conf | sed -e 's/\W\+Option\W\+"Protocol"\W\+"\w\+\W\+#mouse0protocol/    Option        "Protocol" "Microsoft" #mouse0protocol/g' > /tmp/xorg.conf.tmp2
  29.       ;;
  30.      *)
  31.       cat /etc/X11/xorg.conf | sed -e 's/\W\+Option\W\+"Protocol"\W\+"\w\+\W\+#mouse0protocol/    Option        "Protocol" "auto" #mouse0protocol/g' > /tmp/xorg.conf.tmp2
  32.       ;;
  33.     esac
  34.     sync
  35.     cp -f /tmp/xorg.conf.tmp2 /etc/X11/xorg.conf
  36.     sync
  37.     rm -f /tmp/xorg.conf.tmp2
  38.  fi
  39. }
  40.  
  41. #v2.0.0
  42. #read the console keymap (country layout), apply to xkb...
  43. CONSKEYMAP="`cat /etc/keymap | cut -b 1-2`"
  44. [ "$CONSKEYMAP" = "" ] && CONSKEYMAP="us"
  45. case $CONSKEYMAP in
  46.  az) #azerty
  47.   XKEYMAP="fr"
  48.   ;;
  49.  wa) #wangbe
  50.   XKEYMAP="us"
  51.   ;;
  52.  dv) #dvorak
  53.   XKEYMAP="dvorak"
  54.   ;;
  55.  cr) #croat
  56.   XKEYMAP="cz"
  57.   ;;
  58.  sl) #slovene
  59.   XKEYMAP="sk"
  60.   ;;
  61.  uk) #united kingdom
  62.   XKEYMAP="gb"
  63.   ;;
  64.  *)
  65.   XKEYMAP="$CONSKEYMAP"
  66.   ;;
  67. esac
  68.  
  69.  
  70. MAIN1="
  71. <wtitle>Xorg Video Wizard</wtitle>
  72. <hbox>
  73.  <vbox>
  74.   <text><label>\"Welcome to the Puppy Linux
  75. Xorg Video Wizard!\"</label></text>
  76.   <text><label>\"The behaviour of Xorg is controlled
  77. by a configuration file, /etc/X11/
  78. xorg.conf. You have a choice here,
  79. either to completely reconstruct
  80. the /etc/X11/xorg.conf file, or
  81. to modify the existing file.\"</label></text>
  82.  </vbox>
  83.  <vbox>
  84.   <frame XorgWizard>
  85.   <hbox>
  86.    <text><label>XorgWizard completely reconstructs the /etc/X11/xorg.conf file, and X must not be running to do this. A reboot is required, and the Wizard will run in text mode, before X is launched.</label></text>
  87.    <vbox>
  88.     <button>
  89.      <input file>/usr/local/lib/X11/mini-icons/wizard16.xpm</input>
  90.      <action>EXIT:11</action>
  91.     </button>
  92.    </vbox>
  93.   </hbox>
  94.   <text><label>NOTE: You can also run XorgWizard manually, without rebooting, by exiting from X to the commandline (see Shutdown menu) then run xorgwizard.</label></text>
  95.   </frame>
  96.  
  97.   <frame Edit xorg.conf>
  98.    <hbox>
  99.     <text><label>You can manually edit /etc/X11/xorg.conf, but note that you will need to exit from X afterward then restart X (see Shutdown menu). Click button to edit:</label></text>
  100.     <vbox>
  101.      <button>
  102.       <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input>
  103.       <action>EXIT:15</action>
  104.      </button>
  105.     </vbox>
  106.    </hbox>
  107.   </frame>
  108.  
  109.   <frame xvidtune>
  110.    <hbox>
  111.     <text><label>If the screen is displaced or the width/height are wrong, xvidtune can get it right. This will modify the existing xorg.conf file. Use with caution:</label></text>
  112.     <vbox>
  113.      <button>
  114.       <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input>
  115.       <action>EXIT:13</action>
  116.      </button>
  117.     </vbox>
  118.    </hbox>
  119.   </frame>
  120.  
  121.   <frame Resolution changer>
  122.    <hbox>
  123.     <text><label>It is possible to change screen resolutions without exiting from X:</label></text>
  124.     <vbox>
  125.      <button>
  126.       <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input>
  127.       <action>EXIT:18</action>
  128.      </button>
  129.     </vbox>
  130.    </hbox>
  131.   </frame>
  132.  
  133.   <frame Mouse/keyboard Wizard>
  134.    <hbox>
  135.     <text><label>/etc/X11/xorg.conf has generic settings for mouse and keyboard and in most cases it is recommended to leave it as-is. Instead, use the MouseKeyboardWizard:</label></text>
  136.     <vbox>
  137.      <button>
  138.       <input file>/usr/local/lib/X11/mini-icons/wizard16.xpm</input>
  139.       <action>EXIT:16</action>
  140.      </button>
  141.     </vbox>
  142.    </hbox>
  143.   </frame>
  144.  
  145.   <frame Monitor gamma calibration>
  146.    <hbox>
  147.     <text><label>This will adjust the monitor colors, including brightness. Note, cannot save settings -- a project here for someone -- see /usr/share/doc/tkgamma.txt</label></text>
  148.     <vbox>
  149.      <button>
  150.       <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input>
  151.       <action>EXIT:17</action>
  152.      </button>
  153.     </vbox>
  154.    </hbox>
  155.   </frame>
  156.  
  157.  </vbox>
  158. </hbox>
  159. "
  160.  
  161.  
  162. #do this code block if X is running...
  163. if [ ! "`echo -n "$PSFND" | grep "\\.xinitrc"`" = "" ];then
  164.  
  165.  RETSTR="`echo "$MAIN1" | gtkdialog2 --stdin`"
  166.  RETVAL="`echo "$RETSTR" | grep 'EXIT:' | cut -f 2 -d ':'`"
  167.  
  168.  case $RETVAL in
  169.   11) #XorgWizard.
  170.    rm /etc/mousedevice
  171.    mv -f /etc/X11/xorg.conf /etc/X11/xorg.conf.prev 2>/dev/null
  172.    ln -sf Xvesa /usr/X11R6/bin/X
  173.    sync
  174.    exec wmreboot
  175.    ;;
  176.   12) #xorgconfig
  177.    xorgcfg
  178.    xmessage -bg "#ff8080" -center -title "xorgcfg" "Changes to /etc/X11/xorg.conf will only take effect after X is restarted.
  179.  
  180. Click OK button to restart X..."
  181.    exec restartwm
  182.    ;;
  183.   13) #xvidtune
  184.    xmessage -bg violet -title "Xvidtune IMPORTANT HELP" "If you click the 'Show' button, the adjusted settings will be what
  185. you want permanently. After hitting the 'Quit' button, you will be
  186. given one last chance not to make the change permanent.
  187. Thus:
  188. 'Show' to record the settings (for later inclusion into xorg.conf)
  189. 'Quit' to exit Xvidtune.
  190.  
  191. Please note that Xvidtune does not work with all video hardware, meaning
  192. that changing the settings will cause no change on the screen." &
  193.    XMSGPID=$!
  194.    MODELINE0="`xvidtune | grep '^"[0-9]'`"
  195.    kill $XMSGPID
  196.    if [ ! "$MODELINE0" = "" ];then
  197.     xmessage -bg orange -title "Xvidtune: Modeline" -buttons Write:10,Quit:11 "The new modeline is:
  198. $MODELINE0
  199.  
  200. Note, you will have to restart X for it to take effect. If it messes
  201. up X, edit from commandline 'mp /etc/X11/xorg.conf' and comment-out
  202. the 'UseModes' line (do not delete it) in the Monitor section.
  203.  
  204. To insert this into /etc/X11/xorg.conf, click 'Write' button...
  205. To exit without changing xorg.conf, click 'Quit' button..."
  206.     if [ $? -eq 10 ];then
  207.      PATTERNA="s/.*#modes0modeline0/$MODELINE0 #modes0modeline0/g"
  208.      cat /etc/X11/xorg.conf | sed -e "$PATTERNA" > /tmp/xorg.conf.new
  209.      sync
  210.      cat /tmp/xorg.conf.new | sed -e 's/#.*UseModes/UseModes/g' > /etc/X11/xorg.conf
  211.      sync
  212.     fi
  213.    fi
  214.    exit
  215.    ;;
  216.   15) #edit xorg.conf
  217.    exec defaulttexteditor /etc/X11/xorg.conf
  218.    ;;
  219.   16) #mouse/keyboard wizard
  220.    exec input-wizard
  221.    ;;
  222.   17) #tkgamma
  223.    exec tkgamma
  224.    ;;
  225.   18) #resolution changer
  226.    exec xrandrshell
  227.    ;;
  228.  esac
  229.  exit
  230. fi
  231.  
  232. #come here when X is not running, completely rebuild xorg.conf...
  233. if [ -f /etc/X11/xorg.conf ];then
  234. # echo
  235. # echo "/etc/X11/xorg.conf exists. XorgWizard rebuilds it from scratch."
  236. # echo -e "Hit ENTER key to quit, or type \"y\" then ENTER keys to rename"
  237. # echo -n "xorg.conf to xorg.conf.bak and continue XorgWizard: "
  238. # read yeahman
  239. # if [ "$yeahman" = "" ];then
  240. #  exit
  241. # else
  242.   mv -f /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
  243. # fi
  244. fi
  245.  
  246. #comes here first time boot puppy, or whenever bootup
  247. #and xorg.conf has been removed.
  248.  
  249. #need to create xorg.conf so that at subsequent boots, xwin will not run xorgwizard...
  250. cp /etc/X11/xorg.conf0 /etc/X11/xorg.conf
  251.  
  252. dialog --colors --title "Puppy Video Wizard" --yes-label "Xvesa" --no-label "Xorg" --yesno "Welcome to the Puppy Linux Video Wizard!
  253.  
  254. Puppy has two X servers (to run Puppy in graphics mode):
  255. Xvesa: A very small and simple \"Kdrive\" X server.
  256. Xorg:  A very large and sophisticated X server.
  257.  
  258. Up until v1.0.6, Puppy only had Xvesa. This works flawlessly on most
  259. video hardware, very simple to configure, but one major disadvantage
  260. is that screen refresh rate is fixed. Also, Xvesa has limited support
  261. for input devices, and lacks features like acceleration and Xinerama.
  262.  
  263. You can play safe and just press ENTER to launch Xvesa, but later you
  264. will still be able to try Xorg. Alternatively, if you try Xorg now,
  265. and it does not work, you will be able to fall back to Xvesa.
  266.  
  267. Press ENTER key for Xvesa... 
  268. Press TAB then ENTER for Xorg \Z1probing will take several seconds\Zn..." 0 0
  269.  
  270. if [ $? -eq 0 ];then #yes
  271.  ln -sf Xvesa /usr/X11R6/bin/X #Xvesa is now the default X server.
  272.  #when start xorgwizard from commandline, it messes up xorg.conf...
  273.  if [ -f /etc/X11/xorg.conf ];then
  274.   if [ -f /etc/X11/xorg.conf.bak ];then
  275.    #basic test to see that file has right stuff in it...
  276.    if [ "`cat /etc/X11/xorg.conf | grep "VertRefresh"`" = "" ];then
  277.     cp -f /etc/X11/xorg.conf.bak /etc/X11/xorg.conf
  278.    fi
  279.   fi
  280.  fi
  281.  #choosemousefunc #v2.0.0
  282.  exit
  283. fi
  284.  
  285. #resolution changer uses this. it must be removed here...
  286. rm -f /etc/xrandrindex 2> /dev/null
  287.  
  288. ln -sf Xorg /usr/X11R6/bin/X
  289.  
  290. #autoprobe...
  291. clear
  292. Xorg -configure > /tmp/xorgprobe.txt 2>&1
  293. #... config in /root/xorg.conf.new
  294.  
  295. #iterate through /root/xorg.conf.new, finding stuff...
  296.  
  297. #crude loop below gets upset if extra blank lines on end of file, which is
  298. #happening in this case. I think the problem occurs because tail ignores
  299. #the blank lines on end. fix by appending a comment line...
  300. echo '#dummy comment' >> /root/xorg.conf.new
  301.  
  302. XSECTION=""
  303. IDENTIFIER=""
  304. NUMLINES=`wc -l /root/xorg.conf.new | tr -s " " | cut -f 2 -d " "`
  305. REDUCELIST="`cat /root/xorg.conf.new`"
  306. while [ ! $NUMLINES -eq 0 ];do
  307.  HEAD1ST="`echo "$REDUCELIST" | head -n 1`"
  308.  NUMLINES=`expr $NUMLINES - 1`
  309.  REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`"
  310.  if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"ServerLayout"'`" = "" ];then
  311.   XSECTION="ServerLayout"
  312.   echo "" >> /etc/X11/xorg.conf
  313.  fi
  314.  if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"InputDevice"'`" = "" ];then
  315.   XSECTION="InputDevice"
  316.   echo "" >> /etc/X11/xorg.conf
  317.  fi
  318.  if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"Device"'`" = "" ];then
  319.   XSECTION="Device"
  320.   echo "" >> /etc/X11/xorg.conf
  321.  fi
  322.  if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"Monitor"'`" = "" ];then
  323.   XSECTION="Monitor"
  324.   echo "" >> /etc/X11/xorg.conf
  325.  fi
  326.  
  327.  if [ ! "`echo -n "$HEAD1ST" | grep '\W\+Identifier\W\+"'`" = "" ];then
  328.   IDENTIFIER="`echo -n "$HEAD1ST" | cut -f 2 -d '"'`"
  329.  fi
  330.  if [ ! "$XSECTION" = "" ];then
  331.   if [ "$HEAD1ST" = "EndSection" ];then
  332.    if [ "$XSECTION" = "Monitor" ];then
  333.     echo '    HorizSync    HORIZSYNC0' >> /etc/X11/xorg.conf
  334.     echo '    VertRefresh  VERTREFRESH0' >> /etc/X11/xorg.conf
  335.     echo '    #UseModes     "Modes0" #monitor0usemodes' >> /etc/X11/xorg.conf
  336.    fi
  337.   fi
  338.   if [ "$HEAD1ST" = "EndSection" ];then
  339.    if [ "$IDENTIFIER" = "Keyboard0" ];then
  340.     echo '    Option      "XkbRules" "xorg"' >> /etc/X11/xorg.conf
  341.     echo '    Option      "XkbModel" "pc102"' >> /etc/X11/xorg.conf
  342.     echo -e "    Option      \"XkbLayout\" \"$XKEYMAP\" #xkeymap0" >> /etc/X11/xorg.conf
  343.    fi
  344.   fi
  345.  
  346.   #reports on forum that auto does not always work for usb mouse...
  347.   if [ "$IDENTIFIER" = "Mouse0" ];then
  348.    if [ ! "`echo -n "$HEAD1ST" |grep '\W\+Option\W\+"Protocol"\W\+"auto"'`" = "" ];then
  349.     if [ "`cat /etc/mousedevice`" = "input/mice" ];then
  350.      HEAD1ST='    Option        "Protocol" "IMPS/2" #mouse0protocol'
  351.     else
  352.      HEAD1ST='    Option        "Protocol" "auto" #mouse0protocol'
  353.     fi
  354.    fi
  355.   fi
  356.   #auto does not work properly for serial mouse...
  357.   if [ "$IDENTIFIER" = "Mouse0" ];then
  358.    if [ ! "`echo -n "$HEAD1ST" |grep '\W\+Option\W\+"Protocol"\W\+"auto"'`" = "" ];then
  359.     if [ ! "`cat /etc/mousedevice | grep 'ttyS'`" = "" ];then
  360.      HEAD1ST='    Option        "Protocol" "Microsoft" #mouse0protocol'
  361.     else
  362.      HEAD1ST='    Option        "Protocol" "auto" #mouse0protocol'
  363.     fi
  364.    fi
  365.   fi
  366.  
  367.   #record card driver info for later in script...
  368.   if [ "$XSECTION" = "Device" ];then
  369.    if [ "$IDENTIFIER" = "Card0" ];then
  370.     FBODY="`echo -n "$HEAD1ST" | cut -f 2 -d '"'`"
  371.     if [ ! "`echo -n "$HEAD1ST" | grep "\W\+Driver"`" = "" ];then
  372.      CARD0DRIVER="$FBODY"
  373.      #attach a comment, for later in script...
  374.      HEAD1ST="$HEAD1ST #card0driver"
  375.     fi
  376.     [ ! "`echo -n "$HEAD1ST" | grep "\W\+VendorName"`" = "" ] && CARD0VENDOR="$FBODY"
  377.     [ ! "`echo -n "$HEAD1ST" | grep "\W\+BoardName"`" = "" ] && CARD0BOARD="$FBODY"
  378.    fi
  379.   fi
  380.  
  381.   #marv on forum had to comment-out this line...
  382.   if [ ! "`echo -n "$HEAD1ST" | grep "Screen1" | grep "Right Of" | grep "Screen0"`" = "" ];then
  383.    HEAD1ST="#${HEAD1ST}"
  384.   fi
  385.  
  386.   #THIS IS WHERE EACH LINE GETS WRITTEN TO xorg.conf...
  387.   if [ "$XSECTION" = "Monitor" ];then
  388.    #screen out these lines, as they are added above, then edited further down...
  389.    if [ "`echo -n "$HEAD1ST" | grep --extended-regexp "HorizSync|VertRefresh"`" = "" ];then
  390.     echo "$HEAD1ST" >> /etc/X11/xorg.conf
  391.    fi
  392.   else
  393.    #append...
  394.    #the lines of modules get copied through from xorg.conf.new to xorg.conf here...
  395.    echo "$HEAD1ST" >> /etc/X11/xorg.conf
  396.   fi
  397.  
  398.   if [ ! "`echo -n "$HEAD1ST" | grep "/dev/mouse"`" = "" ];then
  399.    if [ "`cat /etc/xextraoptions | grep "\\-2button"`" = "" ];then
  400.     echo '    #Option      "Emulate3Buttons"' >> /etc/X11/xorg.conf
  401.     echo '    #Option      "Emulate3Timeout" "50"' >> /etc/X11/xorg.conf
  402.    else
  403.     echo '    Option      "Emulate3Buttons"' >> /etc/X11/xorg.conf
  404.     echo '    Option      "Emulate3Timeout" "50"' >> /etc/X11/xorg.conf
  405.    fi
  406.    if [ "`cat /etc/mousebuttons`" = "5" ];then #scrollwheel
  407.     echo '    Option      "ZAxisMapping" "4 5" #scrollwheel' >> /etc/X11/xorg.conf
  408.    else
  409.     echo '    #Option      "ZAxisMapping" "4 5" #scrollwheel' >> /etc/X11/xorg.conf
  410.    fi
  411.   fi
  412.  
  413.   #this case, have completed writing Monitor section, insert Modes section below it...
  414.   if [ "$HEAD1ST" = "EndSection" ];then #"EndSection" for Monitor section already written.
  415.    if [ "$XSECTION" = "Monitor" ];then
  416.     echo >> /etc/X11/xorg.conf
  417.     echo 'Section "Modes"' >> /etc/X11/xorg.conf
  418.     echo '    Identifier "Modes0"' >> /etc/X11/xorg.conf
  419.     echo '    #modes0modeline0' >> /etc/X11/xorg.conf
  420.     echo 'EndSection' >> /etc/X11/xorg.conf
  421.    fi
  422.   fi
  423.  
  424.  fi
  425.  
  426.  if [ "$HEAD1ST" = "EndSection" ];then
  427.   XSECTION=""
  428.   IDENTIFIER=""
  429.  fi
  430.  sync
  431. done
  432. #now have an almost-working xorg.conf, missing Screen section.
  433.  
  434.  
  435. #want to choose a resolution and color-depth...
  436. #modes supported by card...
  437. VIDEOCHOICES=""
  438. if [ -f /usr/X11R6/bin/Xvesa ];then
  439.  Xvesa -listmodes > /tmp/Xmodes.txt 2>&1
  440.  VIDEOCHOICES="`cat /tmp/Xmodes.txt | grep --extended-regexp "640x480x16|640x480x24|800x600x16|800x600x24|1024x768x16|1024x768x24|1280x800x16|1280x800x24|1280x960x16|1280x960x24|1280x1024x16|1280x1024x24|1600x1200x16|1600x1200x24|1920x1440x16|1920x1440x24" | tr ':' ' ' | tr -s ' ' | cut -f 2 -d " " | sort`"
  441. fi
  442.  
  443. #check that these are handled by monitor...
  444. HORIZSYNC="`cat /root/xorg.conf.new | grep "HorizSync" | grep -v "SecondMonitor" | head -n 1 | tr -s " " | cut -f 2-9 -d " "`"
  445. VERTREFRESH="`cat /root/xorg.conf.new | grep "VertRefresh" | grep -v "SecondMonitor" | head -n 1 | tr -s " " | cut -f 2-9 -d " "`"
  446.  
  447. #an alternative to Xorg monitor probe...
  448. EDIDPROBE="`get-edid 2>/dev/null | parse-edid 2>/dev/null`"
  449. HORIZSYN3="`echo "$EDIDPROBE" | grep "HorizSync" | head -n 1 | tr -s " " | cut -f 2-4 -d " " | cut -f 1 -d "."`"
  450. VERTREFRES3="`echo "$EDIDPROBE" | grep "VertRefresh" | head -n 1 | tr -s " " | cut -f 2-4 -d " " | cut -f 1 -d "."`"
  451.  
  452. #Xorg monitor probing is very flakey. sometimes reports a monitor is not
  453. #plugnplay, yet at other time reports it is...
  454. #so, need to try again with edid...
  455. BOGUSHS=""
  456. BOGUSVR=""
  457. [ "$HORIZSYNC" = "" ] && BOGUSHS="yes2"
  458. [ "$VERTREFRESH" = "" ] && BOGUSVR="yes2"
  459.  
  460. #Xorg is returning bogus parameters on some video hardware...
  461. if [ ! "$HORIZSYNC" = "" ];then
  462.  BOGUSHS="no"
  463.  #tricky, the "-" needs to be backslashed...
  464.  MAXHORIZ=`echo -n "$HORIZSYNC" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'`
  465.  MINHORIZ=`echo -n "$HORIZSYNC" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'`
  466.  [ $MAXHORIZ -lt 20 ] && BOGUSHS="yes1"
  467.  [ $MAXHORIZ -gt 200 ] && BOGUSHS="yes1"
  468.  [ $MINHORIZ -lt 10 ] && BOGUSHS="yes1"
  469.  [ $MINHORIZ -gt 200 ] && BOGUSHS="yes1"
  470. fi
  471. if [ "$BOGUSHS" = "yes1" ];then
  472.  #Xorg sometimes returns two HorizSync lines, one is correct...
  473.  BOGUSHS="no"
  474.  HORIZSYN2="`cat /root/xorg.conf.new | grep "HorizSync" | grep -v "SecondMonitor" | tail -n 1 | tr -s " " | cut -f 2-9 -d " "`"
  475.  HORIZSYNC="$HORIZSYN2"
  476.  MAXHORIZ=`echo -n "$HORIZSYN2" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'`
  477.  MINHORIZ=`echo -n "$HORIZSYN2" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'`
  478.  [ $MAXHORIZ -lt 20 ] && BOGUSHS="yes2"
  479.  [ $MAXHORIZ -gt 200 ] && BOGUSHS="yes2"
  480.  [ $MINHORIZ -lt 10 ] && BOGUSHS="yes2"
  481.  [ $MINHORIZ -gt 200 ] && BOGUSHS="yes2"
  482. fi
  483. if [ "$BOGUSHS" = "yes2" ];then
  484.  #now try edid...
  485.  BOGUSHS=""
  486.  HORIZSYNC="$HORIZSYN3"
  487.  if [ ! "$HORIZSYNC" = "" ];then
  488.   BOGUSHS="no"
  489.   MAXHORIZ=`echo -n "$HORIZSYN3" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'`
  490.   MINHORIZ=`echo -n "$HORIZSYN3" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'`
  491.   [ $MAXHORIZ -lt 20 ] && BOGUSHS="yes"
  492.   [ $MAXHORIZ -gt 200 ] && BOGUSHS="yes"
  493.   [ $MINHORIZ -lt 10 ] && BOGUSHS="yes"
  494.   [ $MINHORIZ -gt 200 ] && BOGUSHS="yes"
  495.  fi
  496. fi
  497. if [ ! "$VERTREFRESH" = "" ];then
  498.  BOGUSVR="no"
  499.  MAXVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'`
  500.  MINVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'`
  501.  [ $MAXVERT -lt 20 ] && BOGUSVR="yes2"
  502.  [ $MAXVERT -gt 400 ] && BOGUSVR="yes2"
  503.  [ $MINVERT -lt 10 ] && BOGUSVR="yes2"
  504.  [ $MINVERT -gt 200 ] && BOGUSVR="yes2"
  505. fi
  506. if [ "$BOGUSVR" = "yes2" ];then
  507.  #now try edid...
  508.  BOGUSVR=""
  509.  VERTREFRESH="$VERTREFRES3"
  510.  if [ ! "$VERTREFRESH" = "" ];then
  511.   BOGUSVR="no"
  512.   MAXVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'`
  513.   MINVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'`
  514.   [ $MAXVERT -lt 20 ] && BOGUSVR="yes"
  515.   [ $MAXVERT -gt 400 ] && BOGUSVR="yes"
  516.   [ $MINVERT -lt 10 ] && BOGUSVR="yes"
  517.   [ $MINVERT -gt 200 ] && BOGUSVR="yes"
  518.  fi
  519. fi
  520.  
  521. #precaution...
  522. [ "$VERTREFRESH" = "" ] && BOGUSVR="yes"
  523. [ "$HORIZSYNC" = "" ] && BOGUSHS="yes"
  524.  
  525. #if either BOGUSHS or BOGUSVR are "yes" or "" then will have to reject probe...
  526. if [ ! "$BOGUSHS$BOGUSVR" = "nono" ];then
  527.  PLUGNPLAY="no"
  528.  while [ 1 ];do
  529.  #need a dialog, ask generic monitor type...
  530.  dialog --no-collapse --no-cancel --title "Xorg Video Wizard" --radiolist "Automatic probing of your monitor was unsuccessful, so you now need\nto choose from a list of generic monitor types.\nChoose the highest specification that describes your monitor.\nLCD: Liquid Crystal Display. CRT: Cathode Ray Tube (normal monitor)\nChose OTHER if you have the monitor user manual, and it has the\nhorizontal and vertical frequency specifications.\nDOWN-ARROW, press SPACEBAR on desired choise, ENTER key to finish..."  0 0 0 \
  531.  "h31.5v40-70" "LCD Panel 640x480" off \
  532.  "h31.5-37v40-70" "LCD Panel 800x600" off \
  533.  "h31.5-48.5v40-70" "LCD Panel 1024x768" off \
  534.  "h31.5-67v50-75" "LCD Panel 1280x1024" off \
  535.  "h31.5-90v59-75" "LCD Panel 1400x1050" off \
  536.  "h31.5-100v59.0-75.0" "LCD Panel 1440x900" off \
  537.  "h31.5-90v60" "LCD Panel 1600x1200" off \
  538.  "h31.5-90v60" "LCD Panel 1920x1200" off \
  539.  "h31.5v50-61" "CRT Monitor 640x480" off \
  540.  "h31.5-35v50-61" "CRT Monitor 800x600 (cheap old 14inch monitor)" off \
  541.  "h31.5-48.5v56-72" "CRT Monitor 1024x768 (basic 15inch monitor)" on \
  542.  "h31.5-79v50-90" "CRT Monitor 1280x1024 (basic 17inch monitor)" off \
  543.  "h31.5-90v50-90" "CRT Monitor 1400x1050" off \
  544.  "h31.5-94v50-90" "CRT Monitor 1600x1200" off \
  545.  "OTHER" "SELECT THIS IF YOU KNOW MONITOR FREQUENCY SPECS" off \
  546.  2>/tmp/taggen.txt
  547.  CHOSENGEN="`cat /tmp/taggen.txt 2>/dev/null`"
  548.  [ "$CHOSENGEN" = "" ] && continue
  549.  if [ "$CHOSENGEN" = "OTHER" ];then
  550.   dialog --title "Xorg Video Wizard" --inputbox "Please enter the horizontal frequency range of the monitor, in KHz. An example is given:" 0 0 "31.5-48.5" 2>/tmp/taghoriz.txt
  551.   dialog --title "Xorg Video Wizard" --inputbox "Please enter the vertical frequency range of the monitor, in Hz. An example is given:" 0 0 "56-72" 2>/tmp/tagvert.txt
  552.   HORIZSYNC="`cat /tmp/taghoriz.txt 2>/dev/null`"
  553.   VERTREFRESH="`cat /tmp/tagvert.txt 2>/dev/null`"
  554.   [ "$HORIZSYNC" = "" ] && continue
  555.   [ "$VERTREFRESH" = "" ] && continue
  556.  else
  557.   HORIZSYNC="`echo -n "$CHOSENGEN" | cut -f 1 -d "v" | cut -f 2 -d "h"`"
  558.   VERTREFRESH="`echo -n "$CHOSENGEN" | cut -f 2 -d "v"`"
  559.  fi
  560.  break
  561.  done
  562. fi
  563.  
  564. #we now have horiz and vert specs to work with...
  565. #tricky, the "-" needs to be backslashed...
  566.  MAXVERT=`echo -n "$VERTREFRESH" | tr "\-" " " | tr " " "\n" | tr "," "\n" | tail -n 1 | cut -f 1 -d '.'`
  567.  MINVERT=`echo -n "$VERTREFRESH" | tr "\-" " " | tr " " "\n" | tr "," "\n" | head -n 1 | cut -f 1 -d '.'`
  568.  MAXHORIZ=`echo -n "$HORIZSYNC" | tr "\-" " " | tr " " "\n" | tr "," "\n" | tail -n 1 | cut -f 1 -d '.'`
  569.  MINHORIZ=`echo -n "$HORIZSYNC" | tr "\-" " " | tr " " "\n" | tr "," "\n" | head -n 1 | cut -f 1 -d '.'`
  570.  
  571. # echo "MAXVERT=$MAXVERT" > /tmp/tmp.tmp
  572. # echo "MINVERT=$MINVERT" >> /tmp/tmp.tmp
  573. # echo "MAXHORIZ=$MAXHORIZ" >> /tmp/tmp.tmp
  574. # echo "MINHORIZ=$MINHORIZ" >> /tmp/tmp.tmp
  575.  
  576. if [ "$PLUGNPLAY" = "no" ];then
  577.  MSGSUPPORTED="supported Confirmed supported by video card, perhaps also monitor."
  578.  MSGUNKNOWN='monitor   Unconfirmed for card, but perhaps okay for monitor.'
  579. else
  580.  MSGSUPPORTED="supported Confirmed supported by the video card and monitor."
  581.  MSGUNKNOWN='monitor   Unconfirmed for card, but probably okay for monitor.'
  582. fi
  583.  
  584.  echo -n "" > /tmp/xreses.txt
  585.  for ACHOICE in 640x480 800x600 1024x768 1280x800 1280x960 1280x1024 1600x1200 1920x1440
  586.  do
  587.   TRYVERT=$MAXVERT
  588.   TRYRESX="`echo -n "$ACHOICE" | cut -f 1 -d 'x'`"
  589.   TRYRESY="`echo -n "$ACHOICE" | cut -f 2 -d 'x'`"
  590.   while [ 1 ];do
  591.    NEEDHORIZ=`gtf $TRYRESX $TRYRESY $TRYVERT | head -n 2 | tail -n 1 | cut -f 1 -d ';' | cut -f 2 -d ':' | cut -f 2 -d ' ' | cut -f 1 -d '.'`
  592.    RESXY="${TRYRESX}x${TRYRESY}"
  593.    STATUS16="off"
  594.    [ "$RESXY" = '1024x768' ] && STATUS16="on" #set default
  595.    if [ $NEEDHORIZ -gt $MAXHORIZ ];then
  596.     TRYVERT=`expr $TRYVERT - 1`
  597.     if [ $TRYVERT -lt $MINVERT ];then
  598.      echo -n "${RESXY}x16 dangerous $STATUS16 " >> /tmp/xreses.txt
  599.      echo -n "${RESXY}x24 dangerous off " >> /tmp/xreses.txt
  600.      break
  601.     fi
  602.    else
  603.     if [ "`echo "$VIDEOCHOICES" | grep "$RESXY"`" = "" ];then
  604.      echo -n "${RESXY}x16 monitor $STATUS16 " >> /tmp/xreses.txt
  605.      echo -n "${RESXY}x24 monitor off " >> /tmp/xreses.txt
  606.     else
  607.      echo -n "${RESXY}x16 supported $STATUS16 " >> /tmp/xreses.txt
  608.      echo -n "${RESXY}x24 supported off " >> /tmp/xreses.txt
  609.     fi
  610.     break
  611.    fi
  612.   done
  613.  done
  614.  
  615. FINALCHOICES="`cat /tmp/xreses.txt`"
  616.  
  617. dialog --no-collapse --no-cancel --title "Xorg Video Wizard" --radiolist "Please choose a video mode. The format is widthxheightxbits.
  618. Width and height are in pixels, 16/24 bits = 65,536/16,777,216 colors.
  619. Note: $MSGSUPPORTED
  620.       $MSGUNKNOWN
  621.       dangerous Uncomfirmed for card, unconfirmed for monitor.
  622.  
  623. DOWN-ARROW then press SPACEBAR on desired choice then press ENTER key..." 0 0 0 $FINALCHOICES 2>/tmp/tag.txt
  624.  
  625. CHOSENRES="`cat /tmp/tag.txt 2>/dev/null`"
  626. if [ "$CHOSENRES" = "" ];then
  627.  CHOSENRES="800x600x16"
  628. fi
  629.  
  630. #now write the Screen section...
  631. FINALDEPTH="`echo -n "$CHOSENRES" | cut -f 3 -d 'x'`"
  632. CHOSENX="`echo -n "$CHOSENRES" | cut -f 1 -d 'x'`"
  633. CHOSENY="`echo -n "$CHOSENRES" | cut -f 2 -d 'x'`"
  634. FINALXY="${CHOSENX}x${CHOSENY}"
  635. SCRNSECTION="
  636. Section \"Screen\"
  637.     Identifier \"Screen0\"
  638.     Device     \"Card0\"
  639.     Monitor    \"Monitor0\"
  640.     DefaultDepth $FINALDEPTH
  641.     Subsection \"Display\"
  642.         Depth       $FINALDEPTH
  643.         Modes       \"${FINALXY}\"
  644.     EndSubsection
  645. EndSection
  646. "
  647. echo "$SCRNSECTION" >> /etc/X11/xorg.conf
  648.  
  649. #horiz and vert sync ranges were found earlier but not written...
  650. cp -f /etc/X11/xorg.conf /tmp/xorg.conf.tmp
  651. APATTERN="s/HORIZSYNC0/$HORIZSYNC/g"
  652. cat /etc/X11/xorg.conf | sed -e "$APATTERN" > /tmp/xorg.conf.tmp2
  653. BPATTERN="s/VERTREFRESH0/$VERTREFRESH/g"
  654. sync
  655. cat /tmp/xorg.conf.tmp2 | sed -e "$BPATTERN" > /etc/X11/xorg.conf
  656. sync
  657. rm -f /tmp/xorg.conf.tmp2
  658.  
  659. #code here to test the video...
  660.  
  661. while [ 1 ];do #testloop
  662. MOUSEDEV="`cat /etc/mousedevice`"
  663. [ "$MOUSEDEV" = "input/mice" ] && MOUSETYPE="usb"
  664. [ "$MOUSEDEV" = "psaux" ] && MOUSETYPE="ps/2"
  665. [ "`echo -n "$MOUSEDEV" | cut -b 1-3`" = "tty" ] && MOUSETYPE="serial"
  666. dialog --title "Xorg Video Wizard" --yes-label "TEST_X_NOW" --no-label "Change_mouse" --yesno "Okay, just about to take the plunge.
  667.  
  668. Puppy thinks that you have a $MOUSETYPE mouse.
  669. If this is wrong, you must choose the 'Change_mouse' button now.
  670.  
  671. After choosing 'TEST_X_NOW' button, if the next screen shows a nice
  672. dialog box, then X started okay. If the screen is blank or garbage,
  673. then failure.
  674. If successful, click the OKAY button within 40 seconds to confirm.
  675. If garbage or nothing displays, you can press the key combination
  676. CTRL-ALT-BACKSPACE to terminate the test, or just wait 40 seconds
  677. for the test to timeout.
  678.  
  679. Press ENTER key now to start X graphics mode (may take a few secs)...
  680. TAB then ENTER to change the mouse (afterward will return here)..." 0 0
  681.  
  682. if [ ! $? -eq 0 ];then
  683.  #change the mouse... (then go back up to above dialog)
  684.  choosemousefunc
  685.  continue
  686. fi
  687.  
  688. Xorg  > /dev/null 2>&1 &
  689. sleep 3
  690.  
  691. TESTMODELINE="`xvidtune -display :0 -show | tr -s " "`"
  692. CLOCKMHZ=`echo -n "$TESTMODELINE" | cut -f 2 -d " "`
  693. CLOCKHZ=`dc $CLOCKMHZ 1000000 \* p`
  694. if [ ! "$CLOCKHZ" = "0" ];then
  695.  XTOTAL=`echo -n "$TESTMODELINE" | cut -f 6 -d " "`
  696.  YTOTAL=`echo -n "$TESTMODELINE" | cut -f 10 -d " "`
  697.  XTEST=`echo -n "$TESTMODELINE" | cut -f 3 -d " "`
  698.  YTEST=`echo -n "$TESTMODELINE" | cut -f 7 -d " "`
  699.  VRTEST=`dc $CLOCKHZ $XTOTAL \/ $YTOTAL \/ p`
  700.  HSTEST=`dc $CLOCKHZ $XTOTAL \/ 1000 \/ p`
  701. else
  702.  #some video chips do not work with xvidtune.
  703.  XTEST=`xrandr -display :0 -q | head -n 2 | tail -n 1 | tr -s " " | cut -f 2 -d " "`
  704.  YTEST=`xrandr -display :0 -q | head -n 2 | tail -n 1 | tr -s " " | cut -f 4 -d " "`
  705.  VRTEST=`xrandr -display :0 -q | head -n 2 | tail -n 1 | tr -s " " | cut -f 3 -d '*' | cut -f 1 -d " "`
  706.  # so we calc horiz freq theoretically...
  707.  HSTEST=`gtf $XTEST $YTEST $VRTEST | head -n 2 | tail -n 1 | cut -f 1 -d ';' | cut -f 2 -d ':' | cut -f 2 -d ' ' | cut -f 1 -d '.'`
  708. fi
  709.  
  710.  
  711. #xsetroot -display :0 -grey
  712. xli -display :0 -onroot -quiet /usr/share/images/linuz.gif
  713.  
  714. xmessage -center -timeout 40 -display :0 -default "okay" "Puppy Xorg Video Wizard: testing X
  715.  
  716. If you can see this, then X is working!
  717.  
  718. Current resolution:         ${XTEST}x${YTEST} pixels
  719. Horizontal sync frequency:  $HSTEST KHz
  720. Vertical refresh frequency: $VRTEST Hz (number of times per second
  721.                                         screen image is refreshed)
  722.  
  723. However, if the image is wrong, say displaced on the screen
  724. or distorted, then you will need to tweak /etc/X11/xorg.conf.
  725.  
  726. Please click the OKAY button (or press ENTER key) within 40 seconds,
  727. else the Wizard will assume X is not working at all..."
  728.  
  729. if [ $? -eq 0 ];then
  730.  XTRY="success"
  731. else
  732.  XTRY="fail"
  733. fi
  734. killall Xorg #SIGTERM
  735. sleep 1
  736. pidof Xorg && killall -9 Xorg #SIGKILL
  737. sleep 1
  738. pidof Xorg && killall -3 Xorg
  739.  
  740.  
  741. dialog --no-collapse --title "Xorg Video Wizard" --yes-label "FINISHED" --no-label "Tweak" --yesno "Report on X test: $XTRY
  742.                   Resolution           ${XTEST}x${YTEST} pixels
  743.                   Horizontal frequency $HSTEST KHz
  744.                   Refresh frequency    $VRTEST Hz
  745.  
  746. If you are reporting success, great, but if the display was not quite
  747. right, say displaced or distorted, you now have the option of tweaking
  748. the HorizSync and VertRefresh parameters in /etc/X11/xorg.conf.
  749. Ditto if testing X was an abysmal failure.
  750.  
  751. Note: If you have tweaked away, to no avail, choose \"FINISHED\" and you
  752.       will get one final chance to fall back to using Xvesa.
  753.  
  754. Press ENTER if test was okay (or to fall back to Xvesa)... 
  755. TAB then ENTER to tweak parameters in xorg.conf & retest X..." 0 0
  756.  
  757. if [ $? -eq 0 ];then
  758.  break
  759. fi
  760.  
  761. #v2.0.0
  762. dialog --no-collapse --title "Xorg Video Wizard" --yes-label "Tweak_xorg.conf" --no-label "Generic_driver" --yesno "Before continuing to tweaking xorg.conf, one other thing to consider.
  763. Xorg has a dozen or so drivers for particular video hardware, which
  764. optimises performance for the matching hardware, but sometimes a
  765. driver does not work right or there is no exact driver to match the
  766. hardware. The Intel 'i810' driver is an example that is troublesome.
  767. The workaround for this is that Xorg has a generic driver called
  768. 'vesa' (note, this is not the Xvesa X server!), that works with most
  769. video hardware, but some performance may be lost.
  770.  
  771. The current driver being used by Xorg is '${CARD0DRIVER}', and your video
  772. vendor is:  '${CARD0VENDOR}'
  773. board info: '${CARD0BOARD}'
  774.  
  775. So, if you have already tried 'tweaking' or you know that the Xorg
  776. '${CARD0DRIVER}' driver does not work on your hardware, consider the
  777. generic driver. Click 'Generic_driver' to change Xorg to using the
  778. generic driver, otherwise press ahead and try tweaking..." 0 0
  779. if [ ! $? -eq 0 ];then
  780.  APATTERN="s/.*#card0driver/    Driver      \"vesa\" #card0driver/g"
  781.  cat /etc/X11/xorg.conf | sed -e "$APATTERN" > /tmp/xorg.conf.tmp2
  782.  sync
  783.  cp -f /tmp/xorg.conf.tmp2 /etc/X11/xorg.conf
  784.  continue
  785. fi
  786.  
  787. #tweak...
  788. dialog --no-collapse --title "Xorg Video Wizard" --yes-label "Tweak_refresh" --no-label "Edit_xorg.conf" --yesno "If the graphics mode display was distorted, displaced, or a complete
  789. mess, the simplest option now is to adjust the vertical screen refresh
  790. frequency up or down slightly. 
  791. However, if you are more experienced with Linux and X, you may prefer
  792. to open xorg.conf in a text editor and change whatever you wish.
  793.  
  794. Press ENTER key for the easy option, tweak refresh frequency...
  795. Press TAB then ENTER to open xorg.conf in a text editor..." 0 0
  796.  
  797. if [ $? -eq 0 ];then
  798.  VRTSTN=`echo -n "$VRTEST" | cut -f 1 -d '.'`
  799.  VERT0=`expr $VRTSTN - 15`
  800.  VERT1=`expr $VRTSTN - 10`
  801.  VERT2=`expr $VRTSTN - 5`
  802.  VERT3=$VRTEST #this is exact and may have a decimal point.
  803.  VERT4=`expr $VRTSTN + 5`
  804.  if [ "$PLUGNPLAY" = "no" ];then
  805.   MSGPNP="Your monitor is not plug-and-play so this Wizard cannot determine its
  806. max allowable refresh frequency. A very cheap old monitor may not
  807. handle more than 70Hz, better quality, 85Hz."
  808.  else
  809.   [ $VERT4 -gt $MAXVERT ] && VERT4=$MAXVERT
  810.   MSGPNP="Note, it is unwise to push a monitor too hard. Just go high
  811. enough so that there is no flicker. 72Hz-85Hz usually okay."
  812.  fi
  813.  NEWMAXHORIZ=$MAXHORIZ
  814.  NEEDHORIZ=`gtf $XTEST $YTEST $VERT4 | head -n 2 | tail -n 1 | cut -f 1 -d ';' | cut -f 2 -d ':' | cut -f 2 -d ' ' | cut -f 1 -d '.'`
  815.  MSGV4="Increase the frequency"
  816.  if [ "$PLUGNPLAY" = "no" ];then
  817.   if [ $NEEDHORIZ -gt $MAXHORIZ ];then
  818.    VERT4=`expr $VRTSTN + 2` #cut down the jump.
  819.    MSGV4="Increase. WARNING, WILL ALSO INCR. HORIZ FREQ"
  820.   fi
  821.  else
  822.   if [ $NEEDHORIZ -gt $MAXHORIZ ];then
  823.    VERT4=$VERT3 #no jump allowed.
  824.    MSGV4="NO INCREASE ALLOWED"
  825.   fi
  826.  fi
  827. # "$VERT0" "Reduce to $VERT0 Hz" off \
  828. # "$VERT1" "Reduce to $VERT1 Hz" off \
  829. # "$VERT2" "Reduce to $VERT2 Hz" off \
  830. # "$VERT3" "Current frequency, $VERT3 Hz" on \
  831. # "$VERT4" "Increase to $VERT4 Hz" off \
  832.  dialog --no-cancel --title "Xorg Video Wizard" --radiolist "
  833. Xorg is currently set to refresh the screen $VERT3 times per second.
  834. Taking this up or down may remove distortion etc., but note that the
  835. choices here are only suggested upper limits and Xorg may not use
  836. exactly the frequency chosen here.
  837. $MSGPNP" 0 0 0 \
  838.  "$VERT2" "Reduce the frequency" off \
  839.  "$VERT3" "Current frequency, $VERT3 Hz" on \
  840.  "$VERT4" "$MSGV4" off \
  841.  2>/tmp/tagvert.txt
  842.  
  843. #FUTURE: use xrandr above, to determine alternative lower frequencies.
  844.  
  845.  CHOSENVERT="`cat /tmp/tagvert.txt 2>/dev/null`"
  846.  NEEDHORIZ=`gtf $XTEST $YTEST $CHOSENVERT | head -n 2 | tail -n 1 | cut -f 1 -d ';' | cut -f 2 -d ':' | cut -f 2 -d ' ' | cut -f 1 -d '.'`
  847.  NEEDHORIZ=`expr $NEEDHORIZ + 1` #compensate for rounding off error.
  848.  APATTERN="s/HORIZSYNC0/${HORIZSYNC}/g"
  849.  if [ $NEEDHORIZ -gt $MAXHORIZ ];then
  850.   if [ "$PLUGNPLAY" = "no" ];then
  851.    APATTERN="s/HORIZSYNC0/${MINHORIZ}\\-${NEEDHORIZ}/g"
  852.   fi
  853.  fi
  854.  cat /tmp/xorg.conf.tmp | sed -e "$APATTERN" > /tmp/xorg.conf.tmp2
  855.  BPATTERN="s/VERTREFRESH0/${MINVERT}\\-${CHOSENVERT}/g"
  856.  sync
  857.  cat /tmp/xorg.conf.tmp2 | sed -e "$BPATTERN" > /etc/X11/xorg.conf
  858.  sync
  859.  rm -f /tmp/xorg.conf.tmp2
  860. else
  861.  dialog --no-collapse --title "Xorg Video Wizard" --msgbox "Before editing xorg.conf, consider this...
  862.  
  863. /etx/X11/xorg.conf has these lines in the Monitor section:
  864.   HorizSync    $HORIZSYNC
  865.   VertRefresh  $VERTREFRESH
  866.  
  867. For the resolution that you want to run at, you many want to narrow
  868. -down the specs in xorg.conf. For example, say you want 1024x768@85,
  869. but xorg.conf has VertRefresh 50-160. -- maybe narrow that to 50-85.
  870.  
  871. Press ENTER key to edit xorg.conf..." 0 0
  872.  #edit xorg.conf...
  873.  mp /etc/X11/xorg.conf
  874. fi
  875.  
  876. done #testloop
  877.  
  878. dialog --title "Xorg Video Wizard" --yes-label "DONE" --no-label "Xvesa" --yesno "Just press ENTER key if all is fine and you are ready to run
  879. Puppy with Xorg.
  880.  
  881. If you cannot get Xorg to work, press TAB then ENTER to choose
  882. the \"Xvesa\" button. This will start Puppy with the simple Xvesa
  883. graphics server that runs on most video hardware." 0 0
  884.  
  885. if [ ! $? -eq 0 ];then
  886.  ln -sf Xvesa /usr/X11R6/bin/X
  887. else
  888.  #prevent Xvesa video wizard from running after X has started...
  889.  rm -f /tmp/videomode
  890. fi
  891.  
  892. #move it so people ain't confused seeing it in /root...
  893. mv -f /root/xorg.conf.new /tmp/xorg.conf.new
  894.  
  895.  
  896. ###END###
  897.