home *** CD-ROM | disk | FTP | other *** search
Wrap
#!/bin/sh #(c) Copyright Barry Kauler 2006 www.puppylinux.com PSFND="`ps`" CURRENTX="`readlink /usr/X11R6/bin/X`" #v2.0.0 choosemousefunc() { #assume kernel drivers already loaded. rc.local0 reliably detects usb mouse and loads driver, #ps/2 and serial drivers builtin to kernel. 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 MOUSETYPE="`cat /tmp/testmsx`" MOUSEDEV="psaux" [ "$MOUSETYPE" = "usb" ] && MOUSEDEV="input/mice" if [ "$MOUSETYPE" = "serial" ];then 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 MOUSEDEV="`cat /tmp/testmsx`" fi ln -sf /dev/$MOUSEDEV /dev/mouse echo -n "$MOUSEDEV" > /etc/mousedevice #note, rc.local0 will read this on next boot. #fix mouse protocol for Xorg... if [ -f /etc/X11/xorg.conf ];then case `cat /etc/mousedevice | cut -b 1-4` in "inpu") #"input/mice", usb 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 ;; "ttyS") #ttyS0,1,2,3, serial 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 ;; *) 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 ;; esac sync cp -f /tmp/xorg.conf.tmp2 /etc/X11/xorg.conf sync rm -f /tmp/xorg.conf.tmp2 fi } #v2.0.0 #read the console keymap (country layout), apply to xkb... CONSKEYMAP="`cat /etc/keymap | cut -b 1-2`" [ "$CONSKEYMAP" = "" ] && CONSKEYMAP="us" case $CONSKEYMAP in az) #azerty XKEYMAP="fr" ;; wa) #wangbe XKEYMAP="us" ;; dv) #dvorak XKEYMAP="dvorak" ;; cr) #croat XKEYMAP="cz" ;; sl) #slovene XKEYMAP="sk" ;; uk) #united kingdom XKEYMAP="gb" ;; *) XKEYMAP="$CONSKEYMAP" ;; esac MAIN1=" <wtitle>Xorg Video Wizard</wtitle> <hbox> <vbox> <text><label>\"Welcome to the Puppy Linux Xorg Video Wizard!\"</label></text> <text><label>\"The behaviour of Xorg is controlled by a configuration file, /etc/X11/ xorg.conf. You have a choice here, either to completely reconstruct the /etc/X11/xorg.conf file, or to modify the existing file.\"</label></text> </vbox> <vbox> <frame XorgWizard> <hbox> <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> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/wizard16.xpm</input> <action>EXIT:11</action> </button> </vbox> </hbox> <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> </frame> <frame Edit xorg.conf> <hbox> <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> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input> <action>EXIT:15</action> </button> </vbox> </hbox> </frame> <frame xvidtune> <hbox> <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> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input> <action>EXIT:13</action> </button> </vbox> </hbox> </frame> <frame Resolution changer> <hbox> <text><label>It is possible to change screen resolutions without exiting from X:</label></text> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input> <action>EXIT:18</action> </button> </vbox> </hbox> </frame> <frame Mouse/keyboard Wizard> <hbox> <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> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/wizard16.xpm</input> <action>EXIT:16</action> </button> </vbox> </hbox> </frame> <frame Monitor gamma calibration> <hbox> <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> <vbox> <button> <input file>/usr/local/lib/X11/mini-icons/mini-x.xpm</input> <action>EXIT:17</action> </button> </vbox> </hbox> </frame> </vbox> </hbox> " #do this code block if X is running... if [ ! "`echo -n "$PSFND" | grep "\\.xinitrc"`" = "" ];then RETSTR="`echo "$MAIN1" | gtkdialog2 --stdin`" RETVAL="`echo "$RETSTR" | grep 'EXIT:' | cut -f 2 -d ':'`" case $RETVAL in 11) #XorgWizard. rm /etc/mousedevice mv -f /etc/X11/xorg.conf /etc/X11/xorg.conf.prev 2>/dev/null ln -sf Xvesa /usr/X11R6/bin/X sync exec wmreboot ;; 12) #xorgconfig xorgcfg xmessage -bg "#ff8080" -center -title "xorgcfg" "Changes to /etc/X11/xorg.conf will only take effect after X is restarted. Click OK button to restart X..." exec restartwm ;; 13) #xvidtune xmessage -bg violet -title "Xvidtune IMPORTANT HELP" "If you click the 'Show' button, the adjusted settings will be what you want permanently. After hitting the 'Quit' button, you will be given one last chance not to make the change permanent. Thus: 'Show' to record the settings (for later inclusion into xorg.conf) 'Quit' to exit Xvidtune. Please note that Xvidtune does not work with all video hardware, meaning that changing the settings will cause no change on the screen." & XMSGPID=$! MODELINE0="`xvidtune | grep '^"[0-9]'`" kill $XMSGPID if [ ! "$MODELINE0" = "" ];then xmessage -bg orange -title "Xvidtune: Modeline" -buttons Write:10,Quit:11 "The new modeline is: $MODELINE0 Note, you will have to restart X for it to take effect. If it messes up X, edit from commandline 'mp /etc/X11/xorg.conf' and comment-out the 'UseModes' line (do not delete it) in the Monitor section. To insert this into /etc/X11/xorg.conf, click 'Write' button... To exit without changing xorg.conf, click 'Quit' button..." if [ $? -eq 10 ];then PATTERNA="s/.*#modes0modeline0/$MODELINE0 #modes0modeline0/g" cat /etc/X11/xorg.conf | sed -e "$PATTERNA" > /tmp/xorg.conf.new sync cat /tmp/xorg.conf.new | sed -e 's/#.*UseModes/UseModes/g' > /etc/X11/xorg.conf sync fi fi exit ;; 15) #edit xorg.conf exec defaulttexteditor /etc/X11/xorg.conf ;; 16) #mouse/keyboard wizard exec input-wizard ;; 17) #tkgamma exec tkgamma ;; 18) #resolution changer exec xrandrshell ;; esac exit fi #come here when X is not running, completely rebuild xorg.conf... if [ -f /etc/X11/xorg.conf ];then # echo # echo "/etc/X11/xorg.conf exists. XorgWizard rebuilds it from scratch." # echo -e "Hit ENTER key to quit, or type \"y\" then ENTER keys to rename" # echo -n "xorg.conf to xorg.conf.bak and continue XorgWizard: " # read yeahman # if [ "$yeahman" = "" ];then # exit # else mv -f /etc/X11/xorg.conf /etc/X11/xorg.conf.bak # fi fi #comes here first time boot puppy, or whenever bootup #and xorg.conf has been removed. #need to create xorg.conf so that at subsequent boots, xwin will not run xorgwizard... cp /etc/X11/xorg.conf0 /etc/X11/xorg.conf dialog --colors --title "Puppy Video Wizard" --yes-label "Xvesa" --no-label "Xorg" --yesno "Welcome to the Puppy Linux Video Wizard! Puppy has two X servers (to run Puppy in graphics mode): Xvesa: A very small and simple \"Kdrive\" X server. Xorg: A very large and sophisticated X server. Up until v1.0.6, Puppy only had Xvesa. This works flawlessly on most video hardware, very simple to configure, but one major disadvantage is that screen refresh rate is fixed. Also, Xvesa has limited support for input devices, and lacks features like acceleration and Xinerama. You can play safe and just press ENTER to launch Xvesa, but later you will still be able to try Xorg. Alternatively, if you try Xorg now, and it does not work, you will be able to fall back to Xvesa. Press ENTER key for Xvesa... Press TAB then ENTER for Xorg \Z1probing will take several seconds\Zn..." 0 0 if [ $? -eq 0 ];then #yes ln -sf Xvesa /usr/X11R6/bin/X #Xvesa is now the default X server. #when start xorgwizard from commandline, it messes up xorg.conf... if [ -f /etc/X11/xorg.conf ];then if [ -f /etc/X11/xorg.conf.bak ];then #basic test to see that file has right stuff in it... if [ "`cat /etc/X11/xorg.conf | grep "VertRefresh"`" = "" ];then cp -f /etc/X11/xorg.conf.bak /etc/X11/xorg.conf fi fi fi #choosemousefunc #v2.0.0 exit fi #resolution changer uses this. it must be removed here... rm -f /etc/xrandrindex 2> /dev/null ln -sf Xorg /usr/X11R6/bin/X #autoprobe... clear Xorg -configure > /tmp/xorgprobe.txt 2>&1 #... config in /root/xorg.conf.new #iterate through /root/xorg.conf.new, finding stuff... #crude loop below gets upset if extra blank lines on end of file, which is #happening in this case. I think the problem occurs because tail ignores #the blank lines on end. fix by appending a comment line... echo '#dummy comment' >> /root/xorg.conf.new XSECTION="" IDENTIFIER="" NUMLINES=`wc -l /root/xorg.conf.new | tr -s " " | cut -f 2 -d " "` REDUCELIST="`cat /root/xorg.conf.new`" while [ ! $NUMLINES -eq 0 ];do HEAD1ST="`echo "$REDUCELIST" | head -n 1`" NUMLINES=`expr $NUMLINES - 1` REDUCELIST="`echo -n "$REDUCELIST" | tail -n $NUMLINES`" if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"ServerLayout"'`" = "" ];then XSECTION="ServerLayout" echo "" >> /etc/X11/xorg.conf fi if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"InputDevice"'`" = "" ];then XSECTION="InputDevice" echo "" >> /etc/X11/xorg.conf fi if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"Device"'`" = "" ];then XSECTION="Device" echo "" >> /etc/X11/xorg.conf fi if [ ! "`echo -n "$HEAD1ST" | grep 'Section\W\+"Monitor"'`" = "" ];then XSECTION="Monitor" echo "" >> /etc/X11/xorg.conf fi if [ ! "`echo -n "$HEAD1ST" | grep '\W\+Identifier\W\+"'`" = "" ];then IDENTIFIER="`echo -n "$HEAD1ST" | cut -f 2 -d '"'`" fi if [ ! "$XSECTION" = "" ];then if [ "$HEAD1ST" = "EndSection" ];then if [ "$XSECTION" = "Monitor" ];then echo ' HorizSync HORIZSYNC0' >> /etc/X11/xorg.conf echo ' VertRefresh VERTREFRESH0' >> /etc/X11/xorg.conf echo ' #UseModes "Modes0" #monitor0usemodes' >> /etc/X11/xorg.conf fi fi if [ "$HEAD1ST" = "EndSection" ];then if [ "$IDENTIFIER" = "Keyboard0" ];then echo ' Option "XkbRules" "xorg"' >> /etc/X11/xorg.conf echo ' Option "XkbModel" "pc102"' >> /etc/X11/xorg.conf echo -e " Option \"XkbLayout\" \"$XKEYMAP\" #xkeymap0" >> /etc/X11/xorg.conf fi fi #reports on forum that auto does not always work for usb mouse... if [ "$IDENTIFIER" = "Mouse0" ];then if [ ! "`echo -n "$HEAD1ST" |grep '\W\+Option\W\+"Protocol"\W\+"auto"'`" = "" ];then if [ "`cat /etc/mousedevice`" = "input/mice" ];then HEAD1ST=' Option "Protocol" "IMPS/2" #mouse0protocol' else HEAD1ST=' Option "Protocol" "auto" #mouse0protocol' fi fi fi #auto does not work properly for serial mouse... if [ "$IDENTIFIER" = "Mouse0" ];then if [ ! "`echo -n "$HEAD1ST" |grep '\W\+Option\W\+"Protocol"\W\+"auto"'`" = "" ];then if [ ! "`cat /etc/mousedevice | grep 'ttyS'`" = "" ];then HEAD1ST=' Option "Protocol" "Microsoft" #mouse0protocol' else HEAD1ST=' Option "Protocol" "auto" #mouse0protocol' fi fi fi #record card driver info for later in script... if [ "$XSECTION" = "Device" ];then if [ "$IDENTIFIER" = "Card0" ];then FBODY="`echo -n "$HEAD1ST" | cut -f 2 -d '"'`" if [ ! "`echo -n "$HEAD1ST" | grep "\W\+Driver"`" = "" ];then CARD0DRIVER="$FBODY" #attach a comment, for later in script... HEAD1ST="$HEAD1ST #card0driver" fi [ ! "`echo -n "$HEAD1ST" | grep "\W\+VendorName"`" = "" ] && CARD0VENDOR="$FBODY" [ ! "`echo -n "$HEAD1ST" | grep "\W\+BoardName"`" = "" ] && CARD0BOARD="$FBODY" fi fi #marv on forum had to comment-out this line... if [ ! "`echo -n "$HEAD1ST" | grep "Screen1" | grep "Right Of" | grep "Screen0"`" = "" ];then HEAD1ST="#${HEAD1ST}" fi #THIS IS WHERE EACH LINE GETS WRITTEN TO xorg.conf... if [ "$XSECTION" = "Monitor" ];then #screen out these lines, as they are added above, then edited further down... if [ "`echo -n "$HEAD1ST" | grep --extended-regexp "HorizSync|VertRefresh"`" = "" ];then echo "$HEAD1ST" >> /etc/X11/xorg.conf fi else #append... #the lines of modules get copied through from xorg.conf.new to xorg.conf here... echo "$HEAD1ST" >> /etc/X11/xorg.conf fi if [ ! "`echo -n "$HEAD1ST" | grep "/dev/mouse"`" = "" ];then if [ "`cat /etc/xextraoptions | grep "\\-2button"`" = "" ];then echo ' #Option "Emulate3Buttons"' >> /etc/X11/xorg.conf echo ' #Option "Emulate3Timeout" "50"' >> /etc/X11/xorg.conf else echo ' Option "Emulate3Buttons"' >> /etc/X11/xorg.conf echo ' Option "Emulate3Timeout" "50"' >> /etc/X11/xorg.conf fi if [ "`cat /etc/mousebuttons`" = "5" ];then #scrollwheel echo ' Option "ZAxisMapping" "4 5" #scrollwheel' >> /etc/X11/xorg.conf else echo ' #Option "ZAxisMapping" "4 5" #scrollwheel' >> /etc/X11/xorg.conf fi fi #this case, have completed writing Monitor section, insert Modes section below it... if [ "$HEAD1ST" = "EndSection" ];then #"EndSection" for Monitor section already written. if [ "$XSECTION" = "Monitor" ];then echo >> /etc/X11/xorg.conf echo 'Section "Modes"' >> /etc/X11/xorg.conf echo ' Identifier "Modes0"' >> /etc/X11/xorg.conf echo ' #modes0modeline0' >> /etc/X11/xorg.conf echo 'EndSection' >> /etc/X11/xorg.conf fi fi fi if [ "$HEAD1ST" = "EndSection" ];then XSECTION="" IDENTIFIER="" fi sync done #now have an almost-working xorg.conf, missing Screen section. #want to choose a resolution and color-depth... #modes supported by card... VIDEOCHOICES="" if [ -f /usr/X11R6/bin/Xvesa ];then Xvesa -listmodes > /tmp/Xmodes.txt 2>&1 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`" fi #check that these are handled by monitor... HORIZSYNC="`cat /root/xorg.conf.new | grep "HorizSync" | grep -v "SecondMonitor" | head -n 1 | tr -s " " | cut -f 2-9 -d " "`" VERTREFRESH="`cat /root/xorg.conf.new | grep "VertRefresh" | grep -v "SecondMonitor" | head -n 1 | tr -s " " | cut -f 2-9 -d " "`" #an alternative to Xorg monitor probe... EDIDPROBE="`get-edid 2>/dev/null | parse-edid 2>/dev/null`" HORIZSYN3="`echo "$EDIDPROBE" | grep "HorizSync" | head -n 1 | tr -s " " | cut -f 2-4 -d " " | cut -f 1 -d "."`" VERTREFRES3="`echo "$EDIDPROBE" | grep "VertRefresh" | head -n 1 | tr -s " " | cut -f 2-4 -d " " | cut -f 1 -d "."`" #Xorg monitor probing is very flakey. sometimes reports a monitor is not #plugnplay, yet at other time reports it is... #so, need to try again with edid... BOGUSHS="" BOGUSVR="" [ "$HORIZSYNC" = "" ] && BOGUSHS="yes2" [ "$VERTREFRESH" = "" ] && BOGUSVR="yes2" #Xorg is returning bogus parameters on some video hardware... if [ ! "$HORIZSYNC" = "" ];then BOGUSHS="no" #tricky, the "-" needs to be backslashed... MAXHORIZ=`echo -n "$HORIZSYNC" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'` MINHORIZ=`echo -n "$HORIZSYNC" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'` [ $MAXHORIZ -lt 20 ] && BOGUSHS="yes1" [ $MAXHORIZ -gt 200 ] && BOGUSHS="yes1" [ $MINHORIZ -lt 10 ] && BOGUSHS="yes1" [ $MINHORIZ -gt 200 ] && BOGUSHS="yes1" fi if [ "$BOGUSHS" = "yes1" ];then #Xorg sometimes returns two HorizSync lines, one is correct... BOGUSHS="no" HORIZSYN2="`cat /root/xorg.conf.new | grep "HorizSync" | grep -v "SecondMonitor" | tail -n 1 | tr -s " " | cut -f 2-9 -d " "`" HORIZSYNC="$HORIZSYN2" MAXHORIZ=`echo -n "$HORIZSYN2" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'` MINHORIZ=`echo -n "$HORIZSYN2" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'` [ $MAXHORIZ -lt 20 ] && BOGUSHS="yes2" [ $MAXHORIZ -gt 200 ] && BOGUSHS="yes2" [ $MINHORIZ -lt 10 ] && BOGUSHS="yes2" [ $MINHORIZ -gt 200 ] && BOGUSHS="yes2" fi if [ "$BOGUSHS" = "yes2" ];then #now try edid... BOGUSHS="" HORIZSYNC="$HORIZSYN3" if [ ! "$HORIZSYNC" = "" ];then BOGUSHS="no" MAXHORIZ=`echo -n "$HORIZSYN3" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'` MINHORIZ=`echo -n "$HORIZSYN3" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'` [ $MAXHORIZ -lt 20 ] && BOGUSHS="yes" [ $MAXHORIZ -gt 200 ] && BOGUSHS="yes" [ $MINHORIZ -lt 10 ] && BOGUSHS="yes" [ $MINHORIZ -gt 200 ] && BOGUSHS="yes" fi fi if [ ! "$VERTREFRESH" = "" ];then BOGUSVR="no" MAXVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'` MINVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'` [ $MAXVERT -lt 20 ] && BOGUSVR="yes2" [ $MAXVERT -gt 400 ] && BOGUSVR="yes2" [ $MINVERT -lt 10 ] && BOGUSVR="yes2" [ $MINVERT -gt 200 ] && BOGUSVR="yes2" fi if [ "$BOGUSVR" = "yes2" ];then #now try edid... BOGUSVR="" VERTREFRESH="$VERTREFRES3" if [ ! "$VERTREFRESH" = "" ];then BOGUSVR="no" MAXVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | tail -n 1 | cut -f 1 -d '.'` MINVERT=`echo -n "$VERTREFRESH" | tr '\-' ' ' | tr " " "\n" | tr ',' "\n" | head -n 1 | cut -f 1 -d '.'` [ $MAXVERT -lt 20 ] && BOGUSVR="yes" [ $MAXVERT -gt 400 ] && BOGUSVR="yes" [ $MINVERT -lt 10 ] && BOGUSVR="yes" [ $MINVERT -gt 200 ] && BOGUSVR="yes" fi fi #precaution... [ "$VERTREFRESH" = "" ] && BOGUSVR="yes" [ "$HORIZSYNC" = "" ] && BOGUSHS="yes" #if either BOGUSHS or BOGUSVR are "yes" or "" then will have to reject probe... if [ ! "$BOGUSHS$BOGUSVR" = "nono" ];then PLUGNPLAY="no" while [ 1 ];do #need a dialog, ask generic monitor type... 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 \ "h31.5v40-70" "LCD Panel 640x480" off \ "h31.5-37v40-70" "LCD Panel 800x600" off \ "h31.5-48.5v40-70" "LCD Panel 1024x768" off \ "h31.5-67v50-75" "LCD Panel 1280x1024" off \ "h31.5-90v59-75" "LCD Panel 1400x1050" off \ "h31.5-100v59.0-75.0" "LCD Panel 1440x900" off \ "h31.5-90v60" "LCD Panel 1600x1200" off \ "h31.5-90v60" "LCD Panel 1920x1200" off \ "h31.5v50-61" "CRT Monitor 640x480" off \ "h31.5-35v50-61" "CRT Monitor 800x600 (cheap old 14inch monitor)" off \ "h31.5-48.5v56-72" "CRT Monitor 1024x768 (basic 15inch monitor)" on \ "h31.5-79v50-90" "CRT Monitor 1280x1024 (basic 17inch monitor)" off \ "h31.5-90v50-90" "CRT Monitor 1400x1050" off \ "h31.5-94v50-90" "CRT Monitor 1600x1200" off \ "OTHER" "SELECT THIS IF YOU KNOW MONITOR FREQUENCY SPECS" off \ 2>/tmp/taggen.txt CHOSENGEN="`cat /tmp/taggen.txt 2>/dev/null`" [ "$CHOSENGEN" = "" ] && continue if [ "$CHOSENGEN" = "OTHER" ];then 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 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 HORIZSYNC="`cat /tmp/taghoriz.txt 2>/dev/null`" VERTREFRESH="`cat /tmp/tagvert.txt 2>/dev/null`" [ "$HORIZSYNC" = "" ] && continue [ "$VERTREFRESH" = "" ] && continue else HORIZSYNC="`echo -n "$CHOSENGEN" | cut -f 1 -d "v" | cut -f 2 -d "h"`" VERTREFRESH="`echo -n "$CHOSENGEN" | cut -f 2 -d "v"`" fi break done fi #we now have horiz and vert specs to work with... #tricky, the "-" needs to be backslashed... MAXVERT=`echo -n "$VERTREFRESH" | tr "\-" " " | tr " " "\n" | tr "," "\n" | tail -n 1 | cut -f 1 -d '.'` MINVERT=`echo -n "$VERTREFRESH" | tr "\-" " " | tr " " "\n" | tr "," "\n" | head -n 1 | cut -f 1 -d '.'` MAXHORIZ=`echo -n "$HORIZSYNC" | tr "\-" " " | tr " " "\n" | tr "," "\n" | tail -n 1 | cut -f 1 -d '.'` MINHORIZ=`echo -n "$HORIZSYNC" | tr "\-" " " | tr " " "\n" | tr "," "\n" | head -n 1 | cut -f 1 -d '.'` # echo "MAXVERT=$MAXVERT" > /tmp/tmp.tmp # echo "MINVERT=$MINVERT" >> /tmp/tmp.tmp # echo "MAXHORIZ=$MAXHORIZ" >> /tmp/tmp.tmp # echo "MINHORIZ=$MINHORIZ" >> /tmp/tmp.tmp if [ "$PLUGNPLAY" = "no" ];then MSGSUPPORTED="supported Confirmed supported by video card, perhaps also monitor." MSGUNKNOWN='monitor Unconfirmed for card, but perhaps okay for monitor.' else MSGSUPPORTED="supported Confirmed supported by the video card and monitor." MSGUNKNOWN='monitor Unconfirmed for card, but probably okay for monitor.' fi echo -n "" > /tmp/xreses.txt for ACHOICE in 640x480 800x600 1024x768 1280x800 1280x960 1280x1024 1600x1200 1920x1440 do TRYVERT=$MAXVERT TRYRESX="`echo -n "$ACHOICE" | cut -f 1 -d 'x'`" TRYRESY="`echo -n "$ACHOICE" | cut -f 2 -d 'x'`" while [ 1 ];do 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 '.'` RESXY="${TRYRESX}x${TRYRESY}" STATUS16="off" [ "$RESXY" = '1024x768' ] && STATUS16="on" #set default if [ $NEEDHORIZ -gt $MAXHORIZ ];then TRYVERT=`expr $TRYVERT - 1` if [ $TRYVERT -lt $MINVERT ];then echo -n "${RESXY}x16 dangerous $STATUS16 " >> /tmp/xreses.txt echo -n "${RESXY}x24 dangerous off " >> /tmp/xreses.txt break fi else if [ "`echo "$VIDEOCHOICES" | grep "$RESXY"`" = "" ];then echo -n "${RESXY}x16 monitor $STATUS16 " >> /tmp/xreses.txt echo -n "${RESXY}x24 monitor off " >> /tmp/xreses.txt else echo -n "${RESXY}x16 supported $STATUS16 " >> /tmp/xreses.txt echo -n "${RESXY}x24 supported off " >> /tmp/xreses.txt fi break fi done done FINALCHOICES="`cat /tmp/xreses.txt`" dialog --no-collapse --no-cancel --title "Xorg Video Wizard" --radiolist "Please choose a video mode. The format is widthxheightxbits. Width and height are in pixels, 16/24 bits = 65,536/16,777,216 colors. Note: $MSGSUPPORTED $MSGUNKNOWN dangerous Uncomfirmed for card, unconfirmed for monitor. DOWN-ARROW then press SPACEBAR on desired choice then press ENTER key..." 0 0 0 $FINALCHOICES 2>/tmp/tag.txt CHOSENRES="`cat /tmp/tag.txt 2>/dev/null`" if [ "$CHOSENRES" = "" ];then CHOSENRES="800x600x16" fi #now write the Screen section... FINALDEPTH="`echo -n "$CHOSENRES" | cut -f 3 -d 'x'`" CHOSENX="`echo -n "$CHOSENRES" | cut -f 1 -d 'x'`" CHOSENY="`echo -n "$CHOSENRES" | cut -f 2 -d 'x'`" FINALXY="${CHOSENX}x${CHOSENY}" SCRNSECTION=" Section \"Screen\" Identifier \"Screen0\" Device \"Card0\" Monitor \"Monitor0\" DefaultDepth $FINALDEPTH Subsection \"Display\" Depth $FINALDEPTH Modes \"${FINALXY}\" EndSubsection EndSection " echo "$SCRNSECTION" >> /etc/X11/xorg.conf #horiz and vert sync ranges were found earlier but not written... cp -f /etc/X11/xorg.conf /tmp/xorg.conf.tmp APATTERN="s/HORIZSYNC0/$HORIZSYNC/g" cat /etc/X11/xorg.conf | sed -e "$APATTERN" > /tmp/xorg.conf.tmp2 BPATTERN="s/VERTREFRESH0/$VERTREFRESH/g" sync cat /tmp/xorg.conf.tmp2 | sed -e "$BPATTERN" > /etc/X11/xorg.conf sync rm -f /tmp/xorg.conf.tmp2 #code here to test the video... while [ 1 ];do #testloop MOUSEDEV="`cat /etc/mousedevice`" [ "$MOUSEDEV" = "input/mice" ] && MOUSETYPE="usb" [ "$MOUSEDEV" = "psaux" ] && MOUSETYPE="ps/2" [ "`echo -n "$MOUSEDEV" | cut -b 1-3`" = "tty" ] && MOUSETYPE="serial" dialog --title "Xorg Video Wizard" --yes-label "TEST_X_NOW" --no-label "Change_mouse" --yesno "Okay, just about to take the plunge. Puppy thinks that you have a $MOUSETYPE mouse. If this is wrong, you must choose the 'Change_mouse' button now. After choosing 'TEST_X_NOW' button, if the next screen shows a nice dialog box, then X started okay. If the screen is blank or garbage, then failure. If successful, click the OKAY button within 40 seconds to confirm. If garbage or nothing displays, you can press the key combination CTRL-ALT-BACKSPACE to terminate the test, or just wait 40 seconds for the test to timeout. Press ENTER key now to start X graphics mode (may take a few secs)... TAB then ENTER to change the mouse (afterward will return here)..." 0 0 if [ ! $? -eq 0 ];then #change the mouse... (then go back up to above dialog) choosemousefunc continue fi Xorg > /dev/null 2>&1 & sleep 3 TESTMODELINE="`xvidtune -display :0 -show | tr -s " "`" CLOCKMHZ=`echo -n "$TESTMODELINE" | cut -f 2 -d " "` CLOCKHZ=`dc $CLOCKMHZ 1000000 \* p` if [ ! "$CLOCKHZ" = "0" ];then XTOTAL=`echo -n "$TESTMODELINE" | cut -f 6 -d " "` YTOTAL=`echo -n "$TESTMODELINE" | cut -f 10 -d " "` XTEST=`echo -n "$TESTMODELINE" | cut -f 3 -d " "` YTEST=`echo -n "$TESTMODELINE" | cut -f 7 -d " "` VRTEST=`dc $CLOCKHZ $XTOTAL \/ $YTOTAL \/ p` HSTEST=`dc $CLOCKHZ $XTOTAL \/ 1000 \/ p` else #some video chips do not work with xvidtune. XTEST=`xrandr -display :0 -q | head -n 2 | tail -n 1 | tr -s " " | cut -f 2 -d " "` YTEST=`xrandr -display :0 -q | head -n 2 | tail -n 1 | tr -s " " | cut -f 4 -d " "` VRTEST=`xrandr -display :0 -q | head -n 2 | tail -n 1 | tr -s " " | cut -f 3 -d '*' | cut -f 1 -d " "` # so we calc horiz freq theoretically... 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 '.'` fi #xsetroot -display :0 -grey xli -display :0 -onroot -quiet /usr/share/images/linuz.gif xmessage -center -timeout 40 -display :0 -default "okay" "Puppy Xorg Video Wizard: testing X If you can see this, then X is working! Current resolution: ${XTEST}x${YTEST} pixels Horizontal sync frequency: $HSTEST KHz Vertical refresh frequency: $VRTEST Hz (number of times per second screen image is refreshed) However, if the image is wrong, say displaced on the screen or distorted, then you will need to tweak /etc/X11/xorg.conf. Please click the OKAY button (or press ENTER key) within 40 seconds, else the Wizard will assume X is not working at all..." if [ $? -eq 0 ];then XTRY="success" else XTRY="fail" fi killall Xorg #SIGTERM sleep 1 pidof Xorg && killall -9 Xorg #SIGKILL sleep 1 pidof Xorg && killall -3 Xorg dialog --no-collapse --title "Xorg Video Wizard" --yes-label "FINISHED" --no-label "Tweak" --yesno "Report on X test: $XTRY Resolution ${XTEST}x${YTEST} pixels Horizontal frequency $HSTEST KHz Refresh frequency $VRTEST Hz If you are reporting success, great, but if the display was not quite right, say displaced or distorted, you now have the option of tweaking the HorizSync and VertRefresh parameters in /etc/X11/xorg.conf. Ditto if testing X was an abysmal failure. Note: If you have tweaked away, to no avail, choose \"FINISHED\" and you will get one final chance to fall back to using Xvesa. Press ENTER if test was okay (or to fall back to Xvesa)... TAB then ENTER to tweak parameters in xorg.conf & retest X..." 0 0 if [ $? -eq 0 ];then break fi #v2.0.0 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. Xorg has a dozen or so drivers for particular video hardware, which optimises performance for the matching hardware, but sometimes a driver does not work right or there is no exact driver to match the hardware. The Intel 'i810' driver is an example that is troublesome. The workaround for this is that Xorg has a generic driver called 'vesa' (note, this is not the Xvesa X server!), that works with most video hardware, but some performance may be lost. The current driver being used by Xorg is '${CARD0DRIVER}', and your video vendor is: '${CARD0VENDOR}' board info: '${CARD0BOARD}' So, if you have already tried 'tweaking' or you know that the Xorg '${CARD0DRIVER}' driver does not work on your hardware, consider the generic driver. Click 'Generic_driver' to change Xorg to using the generic driver, otherwise press ahead and try tweaking..." 0 0 if [ ! $? -eq 0 ];then APATTERN="s/.*#card0driver/ Driver \"vesa\" #card0driver/g" cat /etc/X11/xorg.conf | sed -e "$APATTERN" > /tmp/xorg.conf.tmp2 sync cp -f /tmp/xorg.conf.tmp2 /etc/X11/xorg.conf continue fi #tweak... 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 mess, the simplest option now is to adjust the vertical screen refresh frequency up or down slightly. However, if you are more experienced with Linux and X, you may prefer to open xorg.conf in a text editor and change whatever you wish. Press ENTER key for the easy option, tweak refresh frequency... Press TAB then ENTER to open xorg.conf in a text editor..." 0 0 if [ $? -eq 0 ];then VRTSTN=`echo -n "$VRTEST" | cut -f 1 -d '.'` VERT0=`expr $VRTSTN - 15` VERT1=`expr $VRTSTN - 10` VERT2=`expr $VRTSTN - 5` VERT3=$VRTEST #this is exact and may have a decimal point. VERT4=`expr $VRTSTN + 5` if [ "$PLUGNPLAY" = "no" ];then MSGPNP="Your monitor is not plug-and-play so this Wizard cannot determine its max allowable refresh frequency. A very cheap old monitor may not handle more than 70Hz, better quality, 85Hz." else [ $VERT4 -gt $MAXVERT ] && VERT4=$MAXVERT MSGPNP="Note, it is unwise to push a monitor too hard. Just go high enough so that there is no flicker. 72Hz-85Hz usually okay." fi NEWMAXHORIZ=$MAXHORIZ 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 '.'` MSGV4="Increase the frequency" if [ "$PLUGNPLAY" = "no" ];then if [ $NEEDHORIZ -gt $MAXHORIZ ];then VERT4=`expr $VRTSTN + 2` #cut down the jump. MSGV4="Increase. WARNING, WILL ALSO INCR. HORIZ FREQ" fi else if [ $NEEDHORIZ -gt $MAXHORIZ ];then VERT4=$VERT3 #no jump allowed. MSGV4="NO INCREASE ALLOWED" fi fi # "$VERT0" "Reduce to $VERT0 Hz" off \ # "$VERT1" "Reduce to $VERT1 Hz" off \ # "$VERT2" "Reduce to $VERT2 Hz" off \ # "$VERT3" "Current frequency, $VERT3 Hz" on \ # "$VERT4" "Increase to $VERT4 Hz" off \ dialog --no-cancel --title "Xorg Video Wizard" --radiolist " Xorg is currently set to refresh the screen $VERT3 times per second. Taking this up or down may remove distortion etc., but note that the choices here are only suggested upper limits and Xorg may not use exactly the frequency chosen here. $MSGPNP" 0 0 0 \ "$VERT2" "Reduce the frequency" off \ "$VERT3" "Current frequency, $VERT3 Hz" on \ "$VERT4" "$MSGV4" off \ 2>/tmp/tagvert.txt #FUTURE: use xrandr above, to determine alternative lower frequencies. CHOSENVERT="`cat /tmp/tagvert.txt 2>/dev/null`" 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 '.'` NEEDHORIZ=`expr $NEEDHORIZ + 1` #compensate for rounding off error. APATTERN="s/HORIZSYNC0/${HORIZSYNC}/g" if [ $NEEDHORIZ -gt $MAXHORIZ ];then if [ "$PLUGNPLAY" = "no" ];then APATTERN="s/HORIZSYNC0/${MINHORIZ}\\-${NEEDHORIZ}/g" fi fi cat /tmp/xorg.conf.tmp | sed -e "$APATTERN" > /tmp/xorg.conf.tmp2 BPATTERN="s/VERTREFRESH0/${MINVERT}\\-${CHOSENVERT}/g" sync cat /tmp/xorg.conf.tmp2 | sed -e "$BPATTERN" > /etc/X11/xorg.conf sync rm -f /tmp/xorg.conf.tmp2 else dialog --no-collapse --title "Xorg Video Wizard" --msgbox "Before editing xorg.conf, consider this... /etx/X11/xorg.conf has these lines in the Monitor section: HorizSync $HORIZSYNC VertRefresh $VERTREFRESH For the resolution that you want to run at, you many want to narrow -down the specs in xorg.conf. For example, say you want 1024x768@85, but xorg.conf has VertRefresh 50-160. -- maybe narrow that to 50-85. Press ENTER key to edit xorg.conf..." 0 0 #edit xorg.conf... mp /etc/X11/xorg.conf fi done #testloop 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 Puppy with Xorg. If you cannot get Xorg to work, press TAB then ENTER to choose the \"Xvesa\" button. This will start Puppy with the simple Xvesa graphics server that runs on most video hardware." 0 0 if [ ! $? -eq 0 ];then ln -sf Xvesa /usr/X11R6/bin/X else #prevent Xvesa video wizard from running after X has started... rm -f /tmp/videomode fi #move it so people ain't confused seeing it in /root... mv -f /root/xorg.conf.new /tmp/xorg.conf.new ###END###