xorgwizard-cli 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. #!/bin/sh
  2. #(c) Copyright Barry Kauler, April 2013, bkhome.org
  3. #license GPL3 (refer: /usr/share/doc/legal).
  4. #130427 completely rewritten Xorg Wizard. runs without X.
  5. # note, /root/.profile and /usr/sbin/xorgwizard also modified.
  6. #130428 add touchpad support.
  7. #130429 remove /root/xorg.conf.new
  8. #130501 /etc/rc.d/rc.sysinit may create empty /root/xorgwizard-reenter.
  9. #130503 constrain limits of monitor vertical refresh frequency.
  10. #130503 expanded rules to decide whether need to reboot.
  11. #130504 if nv_drv.so present, xorg.conf.new does not have nouveau, and vice-versa.
  12. #130504 customise driver help dlg.
  13. #130504 More resolution choices, including NOTHING.
  14. #130506 backup a prior /etc/X11/xorg.conf.
  15. #130509 advise about typing "xwin [jwm|openbox]".
  16. #130509 fix 130504, nv/nouveau.
  17. #130509 problem with -configure, not detect all possible drivers.
  18. #130513 note, pupdesk.flg code moved from rc.sysinit to init (in intrd).
  19. #130523 when proprietary nvidia driver installed, xorgwizard-cli does not offer it.
  20. #130523 proprietary nvidia installer creates /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
  21. #130524 offer to view content of an alternate xorg.conf file.
  22. export TEXTDOMAIN=xorgwizard-cli
  23. export OUTPUT_CHARSET=UTF-8
  24. . gettext.sh
  25. if [ $DISPLAY ];then
  26. echo
  27. echo "Please exit from X to run this Xorg Wizard."
  28. exit
  29. fi
  30. if [ "$(readlink /usr/bin/X)" != "Xorg" ];then
  31. echo
  32. echo "This script only works for Xorg."
  33. exit
  34. fi
  35. if [ "$(grep 'xorgwizard-cli' /root/.profile)" = "" ];then
  36. echo
  37. echo "/root/.profile is incompatible, aborting."
  38. fi
  39. . /etc/DISTRO_SPECS
  40. . /etc/rc.d/PUPSTATE
  41. . /etc/rc.d/BOOTCONSTRAINED
  42. . /etc/rc.d/functions4puppy4 #choosemousefunc().
  43. if [ "$BOOT_DISABLEXORGWIZARD" = "yes" ];then #refer /etc/rc.d/BOOTCONSTRAINED and 3builddistro.
  44. echo
  45. echo "Sorry, the text-mode Xorg Wizard is disabled for this build of Puppy."
  46. exit
  47. fi
  48. #note, ubuntu precise has 1.11.3, raring has 1.13.0 ...
  49. XORGVER="`Xorg -version 2>&1 | grep '^X Window System Version' | rev | cut -f 1 -d ' ' | rev`" #ex: 1.3.0
  50. [ ! "$XORGVER" ] && XORGVER="`Xorg -version 2>&1 | grep '^X\.Org X Server' | rev | cut -f 1 -d ' ' | rev`"
  51. if vercmp $XORGVER lt 1.11.0; then
  52. echo
  53. echo "Sorry, this script is designed for Xorg version 1.11.0 or greater.
  54. However, it might work on earlier versions, we need to find out
  55. -- edit /usr/sbin/xorgwizard-cli and remove this exit-point."
  56. exit
  57. fi
  58. DLGTITLE="$(gettext 'Puppy Xorg Video Wizard')"
  59. ddcprobe > /tmp/ddcprobe.txt
  60. #weird (ddcprobe is very weird), on some hardware, edid monitor probe fails
  61. #every alternate run of ddcprobe...
  62. case "`cat /tmp/ddcprobe.txt`" in
  63. *edidfail*)
  64. sleep 1
  65. ddcprobe > /tmp/ddcprobe.txt
  66. ;;
  67. esac
  68. ##############################################################
  69. ###RE-ENTER: TEST DRIVER###
  70. ###########################
  71. #130501 empty /root/.xorgwizard-reenter means do a re-probe (refer rc.sysinit)... 130513 refer init in initrd.
  72. if [ -f /root/.xorgwizard-reenter ];then
  73. [ ! -s /root/.xorgwizard-reenter ] && rm -f /root/.xorgwizard-reenter
  74. fi
  75. #if this file exists, then have reentered script, to test the driver...
  76. if [ -f /root/.xorgwizard-reenter ];then
  77. CHOSENDRV="$(cat /root/.xorgwizard-reenter | cut -f 1 -d ' ')"
  78. XLOOP=1
  79. while [ $XLOOP -ne 0 ];do #testloop
  80. case "`cat /etc/mousedevice 2>/dev/null`" in
  81. tty*) MOUSEMSG="$(gettext 'Puppy thinks that you have a serial mouse. However, if your PC has a modern usb or ps/2 mouse, you must choose the <Change mouse> button now.')" ;;
  82. *) MOUSEMSG="$(gettext 'Puppy thinks that you have a usb or ps/2 mouse. However, for an old PC that has a serial mouse, you must choose the <Change mouse> button now.')" ;;
  83. esac
  84. dialog --extra-button --help-button --title "${DLGTITLE}" --ok-label "$(gettext 'TEST X NOW')" --cancel-label "$(gettext 'Change mouse')" --extra-label "$(gettext 'Fallback')" --help-label "$(gettext 'Help')" --yesno "$(gettext 'THE NEXT STEP WILL TEST XORG!')
  85. ${MOUSEMSG}
  86. $(gettext '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 (In such a case, just press the ENTER key to terminate the test, preferably within the 60 second test timeout).')
  87. $(gettext 'IMPORTANT: If the ENTER key does not terminate the test, press the combination CTRL-ALT-BACKSPACE')
  88. $(gettext 'EMERGENCY SHUTDOWN: If the test hangs your PC, reboot by pressing the reset button, or hold down the power button for 4 seconds to shutdown.')
  89. $(gettext 'Press ENTER key now to test X graphics mode (may take a few secs)...')
  90. $(gettext 'TAB then ENTER to use an old working xorg.conf, or create new xorg.conf...')
  91. $(gettext 'TAB, TAB then ENTER to change the mouse (afterward will return here)...')
  92. $(gettext 'Press ESC key to exit Wizard without testing xorg.conf...')" 0 0
  93. case $? in
  94. 1) #change the mouse... (then go back up to above dialog)
  95. choosemousefunc
  96. continue
  97. ;;
  98. 2) #help
  99. dialog --no-cancel --title "${DLGTITLE}: $(gettext 'Help')" --msgbox "$(gettext 'Xorg is the system required for the PC to go into graphical desktop mode.')
  100. $(gettext 'Mouse:')
  101. $(gettext 'Modern PCs have a usb or ps/2 mouse (or touchpad). However, some old PCs have a serial mouse (recognizable by the large rectangular plug), in which case you must choose the <Change mouse> button before continuing with the Wizard.')
  102. $(gettext 'CTRL-ALT-BACKSPACE:')
  103. $(gettext 'This is the standard emergency key combination to terminate Xorg and drop back to the text-mode console. Hold down CTRL and ALT keys then tap the BACKSPACE key. Remember this key combination!')
  104. $(gettext 'Fallback:')
  105. $(gettext 'The Xorg configuration file is /etc/X11/xorg.conf. Choosing this option will offer a choice of all /etc/X11/xorg.conf* files, so if you have previously created one that you know works, you may choose it. Or, you may choose to abort entirely and create a new xorg.conf.')
  106. $(gettext 'Press ENTER key to go back to previous window...')" 0 0
  107. continue
  108. ;;
  109. 3) #use old xorg.conf...
  110. XORGCONFS="$(find /etc/X11 -mindepth 1 -maxdepth 1 -type f -name 'xorg.conf*' | grep -v -E 'conf0|conf-auto|conf-generic|conf.example|xorg.conf$')"
  111. CNT=1; ALTCONFS0=''
  112. for ONEXCF in $XORGCONFS
  113. do
  114. [ ! -f $ONEXCF ] && continue
  115. ALTCONFS0="${ALTCONFS0}
  116. ${CNT} ${ONEXCF}"
  117. CNT=`expr $CNT + 1`
  118. done
  119. ALTCONFS0="${ALTCONFS0}
  120. ${CNT} NONE"
  121. ALTCONFS1="`echo -n "$ALTCONFS0" | tr '\n' ' '`"
  122. #130524 offer to view an alternate xorg.conf file...
  123. echo '#!/bin/sh' > /tmp/xorgwizard-alt-confs
  124. echo "dialog --stdout --extra-button --title \"${DLGTITLE}\" --ok-label \"$(gettext 'OK')\" --extra-label \"$(gettext 'View')\" --cancel-label \"$(gettext 'Cancel')\" --menu \"$(gettext 'Press UP/DOWN arrow keys to choose an old xorg.conf, or NONE to probe and create a new xorg.conf.')
  125. $(gettext 'Note that after highlighting a file, you can select the <View> button to see the content in a text editor, and afterward come back to this window.')
  126. $(gettext 'After choosing file, press ENTER key to choose <OK> button, or')
  127. $(gettext 'press TAB then ENTER to view content of selected file, or')
  128. $(gettext 'TAB, TAB then ENTER keys to abort and go back to previous window...')\" 0 0 0 $ALTCONFS1" >> /tmp/xorgwizard-alt-confs
  129. echo 'exit $?' >> /tmp/xorgwizard-alt-confs
  130. chmod 755 /tmp/xorgwizard-alt-confs
  131. while true; do #130524
  132. NUMALTCONF="`/tmp/xorgwizard-alt-confs`"
  133. altRET=$?
  134. [ "$NUMALTCONF" = "" ] && continue 2
  135. if [ $altRET -eq 3 ];then #View
  136. ALTCONF="`echo "$ALTCONFS0" | grep "^${NUMALTCONF} " | cut -f 2 -d ' '`"
  137. if [ -f $ALTCONF ];then
  138. mp $ALTCONF #mp is a text-mode editor in all pups.
  139. continue
  140. fi
  141. fi
  142. break
  143. done
  144. [ $altRET -ne 0 ] && continue
  145. ALTCONF="`echo "$ALTCONFS0" | grep "^${NUMALTCONF} " | cut -f 2 -d ' '`"
  146. if [ "$ALTCONF" = "NONE" ];then
  147. rm -f /root/.xorgwizard-reenter
  148. exec xorgwizard-cli
  149. fi
  150. [ ! -f $ALTCONF ] && continue #precaution.
  151. cp -f /etc/X11/xorg.conf /etc/X11/xorg.conf-OLD
  152. cp -f $ALTCONF /etc/X11/xorg.conf #use old working xorg.conf.
  153. #precaution, recalculate the hardware profile...
  154. grep -v '^#PuppyHardwareProfile' /etc/X11/xorg.conf > /tmp/xorg.conf.tmp2
  155. PROFILECHIP="`grep -m1 '^oem: ' /tmp/ddcprobe.txt | cut -f 2-4 -d ' ' | tr ' ' '_' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  156. #'eisa:' and 'id:' return fluctuating values on some PCs, so search in this order...
  157. PROFILEMONITOR="`grep '^monitorid: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  158. [ "$PROFILEMONITOR" = "" ] && PROFILEMONITOR="`grep '^monitorname: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  159. [ "$PROFILEMONITOR" = "" ] && PROFILEMONITOR="`grep '^monitorrange: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  160. echo "#PuppyHardwareProfile=${PROFILECHIP}${PROFILEMONITOR}" >> /tmp/xorg.conf.tmp2
  161. cp -f /tmp/xorg.conf.tmp2 /etc/X11/xorg.conf
  162. #create a copy of xorg.conf with the profile in the filename...
  163. cp -af /etc/X11/xorg.conf /etc/X11/xorg.conf.${PROFILECHIP}${PROFILEMONITOR}
  164. clear
  165. echo -en "\\033[1;32m" #34=blue, 33=yellow, 32=green, 31=red, 35=purple, 36=aquablue, 38=black.
  166. echo "$(gettext 'File:') ${ALTCONF}"
  167. echo "$(gettext 'Has been copied to:') /etc/X11/xorg.conf"
  168. echo "$(gettext 'Also backed up as:') /etc/X11/xorg.conf.${PROFILECHIP}${PROFILEMONITOR}"
  169. echo -n "$(gettext 'Type "xwin" (then ENTER key) to start X...')"
  170. echo -e "\\033[0;39m"
  171. exit
  172. ;;
  173. 0) #test X now.
  174. break
  175. ;;
  176. *) #abort (maybe pressed esc key)
  177. touch /tmp/bootcnt.txt #prevent X from starting (see /root/.profile).
  178. rm -f /root/.xorgwizard-reenter #so next run xorgwizard-cli, creates new xorg.conf.
  179. clear
  180. echo -en "\\033[1;36m" #34=blue, 33=yellow, 32=green, 31=red, 35=purple, 36=aquablue, 38=black.
  181. echo "$(gettext 'You have exited from the Xorg Wizard without testing the configuration file /etc/X11/xorg.conf.')"
  182. echo -n "$(gettext 'Type "xwin" (then ENTER key) to start X (the graphical desktop) now, or "xorgwizard" to re-run the Xorg Wizard.')"
  183. echo -e "\\033[0;39m"
  184. echo "$(gettext 'Note, type "xwin jwm" or "xwin openbox" if you have both of these window managers installed and you want to change from the current one. Ditto for any other installed window manager.')"
  185. exit
  186. ;;
  187. esac
  188. done
  189. ###TEST XORG###
  190. export MONCHOICES='' #previous xorgwizard set this, read in xinitrc_test.
  191. xinit /usr/sbin/xinitrc_test -- /usr/bin/Xorg :0
  192. eval "`cat /tmp/xorgwizard_initrc_test_results`" #results from xinitrc_test
  193. #...XTEST, YTEST, HSTEST, VRTEST.
  194. load_consolefont #it seems have to reload console font after exit from X.
  195. dialog --extra-button --no-collapse --title "${DLGTITLE}" --ok-label "$(gettext 'FINISHED')" --cancel-label "$(gettext 'Tweak')" --extra-label "Abort" --yesno "$(gettext 'Report on X test:')
  196. $(eval_gettext "Resolution: \${XTEST}x\${YTEST} pixels")
  197. $(eval_gettext "Horizontal frequency: \${HSTEST} KHz")
  198. $(eval_gettext "Refresh frequency: \${VRTEST} Hz")
  199. $(eval_gettext "Video driver: \${CHOSENDRV}")
  200. $(gettext '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 various parameters, even choose a different video driver. Ditto if testing X was an abysmal failure.')
  201. $(gettext 'Press ENTER key if test was okay...')
  202. $(gettext 'TAB then ENTER to abort and go back to main window...')
  203. $(gettext 'TAB, TAB then ENTER to tweak parameters & retest X...')" 0 0
  204. case $? in
  205. 0) #test was ok.
  206. rm -f /root/.xorgwizard-reenter
  207. clear
  208. echo
  209. echo -en "\\033[1;32m" #34=blue, 33=yellow, 32=green, 31=red, 35=purple, 36=aquablue, 38=black.
  210. echo "$(gettext 'The Puppy Xorg Wizard has been run, presumably successfully.')
  211. $(gettext 'If so, type "xwin" (then ENTER key) to start Xorg and the graphical desktop.')
  212. $(gettext 'Otherwise, you may type "xorgwizard" to re-run the Wizard...')"
  213. echo -e "\\033[0;39m"
  214. echo "$(gettext 'Note, type "xwin jwm" or "xwin openbox" if you have both of these window managers installed and you want to change from the current one. Ditto for any other installed window manager.')"
  215. exit
  216. ;;
  217. 3) #abort
  218. exec xorgwizard-cli ###REENTER###
  219. ;;
  220. 1) #tweak
  221. dialog --title "${DLGTITLE}" --msgbox "$(gettext 'The next step will be to open /etc/X11/xorg.conf in a text editor. Various parameters can be modified, then the file saved, then exit the editor. Please note that this is a text-mode editor that does not work with a mouse.')
  222. $(gettext 'Displaced:')
  223. $(gettext "The most common problem is the image displaced/squeezed/distorted. Often this is due to a wrong vertical refresh frequency (number of times per second that the screen gets re-drawn). You may experiment with the 'VertRefresh' range. Note, 60Hz is usually OK for LCD screens. Older CRT screens may flicker at 60Hz, usually need at least 70Hz.")" 0 0
  224. mp /etc/X11/xorg.conf
  225. exec xorgwizard-cli ###REENTER###
  226. ;;
  227. esac
  228. exit
  229. fi
  230. #####################################################################
  231. ###create /etc/X11/xorg.conf###
  232. ###############################
  233. #during woof build, may have put some drivers here...
  234. cp -a -f --remove-destination /usr/lib/x/drivers-alternate/* /usr/lib/xorg/modules/drivers/ 2> /dev/null
  235. rm -f /usr/lib/x/drivers-alternate/* 2> /dev/null
  236. #130428 touchpad support...
  237. FLAGTOUCHPAD="$(grep -E 'Elantech|Alps|Synaptics' /proc/bus/input/devices)"
  238. if [ "$FLAGTOUCHPAD" ];then
  239. if [ "`lsmod | grep '^evdev'`" == "" ];then
  240. modprobe evdev
  241. [ "`grep '^modprobe evdev' /etc/rc.d/rc.local`" == "" ] && echo "modprobe evdev" >> /etc/rc.d/rc.local
  242. fi
  243. fi
  244. #find out current video basics...
  245. KMS_i915="$(grep -o 'modeset=[01]' /etc/modprobe.d/i915.conf | cut -f 2 -d '=')"
  246. KMS_nouveau="$(grep -o 'modeset=[01]' /etc/modprobe.d/nouveau.conf | cut -f 2 -d '=')"
  247. KMS_radeon="$(grep -o 'modeset=[01]' /etc/modprobe.d/radeon.conf | cut -f 2 -d '=')"
  248. KMS_all="${KMS_i915}${KMS_nouveau}${KMS_radeon}"
  249. KERNVER="$(uname -r)"
  250. GPUDRM_PATH="$(find /lib/modules/${KERNVER}/kernel/drivers -type f -name i915.ko | sed -e 's%/i915\.ko$%%' -e 's%/i915$%%')"
  251. #...ex: GPUDRM_PATH=/lib/modules/3.8.4/kernel/drivers/gpu/drm
  252. GPUDRM_MODS="$(ls ${GPUDRM_PATH}/*/*.ko | rev | cut -f 1 -d '/' | cut -f 2 -d '.' | rev)" #list all gpu drm modules.
  253. ALL_LOADED_MODS="$(lsmod | grep -v '^Module' | cut -f 1 -d ' ')"
  254. echo "$ALL_LOADED_MODS" > /tmp/xorgwizard-loaded-mods
  255. echo "$GPUDRM_MODS" > /tmp/xorgwizard-all-gpudrm-mods
  256. GPUDRM_LOADED_MODS="$(grep -f /tmp/xorgwizard-loaded-mods -w /tmp/xorgwizard-all-gpudrm-mods)"
  257. #...ex: i915\nnouveau\nttm\n
  258. #130523 difficult situation if proprietary nvidia installer has created this file, with these contents:
  259. ## generated by nvidia-installer
  260. #blacklist nouveau
  261. #options nouveau modeset=0
  262. if [ -f /etc/modprobe.d/nvidia-installer-disable-nouveau.conf ];then
  263. if [ "$(echo "$GPUDRM_LOADED_MODS" | grep '^nouveau$')" = "" ];then
  264. #bootup has occurred with this file in place, so nouveau was blacklisted.
  265. echo 'options nouveau modeset=0' > /etc/modprobe.d/nouveau.conf
  266. KMS_nouveau="0"
  267. else
  268. #have installed proprietary nvidia driver but not yet rebooted.
  269. true
  270. fi
  271. rm -f /etc/modprobe.d/nvidia-installer-disable-nouveau.conf
  272. fi
  273. #process the above info a bit...
  274. ACTIVE_KMS_i915="0"; ACTIVE_KMS_nouveau="0"; ACTIVE_KMS_radeon="0"
  275. [ "$KMS_i915" = "1" ] && [ "$(echo "$GPUDRM_LOADED_MODS" | grep '^i915$')" != "" ] && ACTIVE_KMS_i915="1"
  276. [ "$KMS_nouveau" = "1" ] && [ "$(echo "$GPUDRM_LOADED_MODS" | grep '^nouveau$')" != "" ] && ACTIVE_KMS_nouveau="1"
  277. [ "$KMS_radeon" = "1" ] && [ "$(echo "$GPUDRM_LOADED_MODS" | grep '^radeon$')" != "" ] && ACTIVE_KMS_radeon="1"
  278. ACTIVE_KMS_PTN="${ACTIVE_KMS_i915}${ACTIVE_KMS_nouveau}${ACTIVE_KMS_radeon}"
  279. cp -f /etc/X11/xorg.conf0 /tmp/xorg.conf.tmp
  280. clear
  281. echo -en "\\033[1;35m" #34=blue, 33=yellow, 32=green, 31=red, 35=purple, 36=aquablue, 38=black.
  282. echo -n "$(gettext 'Probing video hardware, please wait...')"
  283. echo -e "\\033[0;39m"
  284. if [ "$FLAGTOUCHPAD" ];then #130428
  285. OLD1='Section "Module"'
  286. NEW1='Section "Module"\n Load "synaptics" #loadsynaptics'
  287. tPTN="s%${OLD1}%${NEW1}%"
  288. sed -i "$tPTN" /tmp/xorg.conf.tmp
  289. fi
  290. #130428
  291. echo 'Section "ServerLayout"
  292. Identifier "Default Layout"
  293. Screen "Screen0" 0 0
  294. InputDevice "Keyboard0" "CoreKeyboard"
  295. InputDevice "Mouse0" "CorePointer"' >> /tmp/xorg.conf.tmp
  296. [ "$FLAGTOUCHPAD" ] && echo ' InputDevice "SynapticsMouse" "AlwaysCore" #serverlayoutsynaptics' >> /tmp/xorg.conf.tmp
  297. echo -e 'EndSection' >> /tmp/xorg.conf.tmp
  298. #autoprobe...
  299. Xorg -configure > /tmp/xorgprobe.txt 2>&1 #... config in /root/xorg.conf.new
  300. #now edit sections from /root/xorg.conf.new and append to /etc/X11/xorg.conf...
  301. ###Keyboard###
  302. XKEYMAP='us'
  303. RETVALS="`keymap-set --xopt`"
  304. eval "$RETVALS" #ex: XKBMODEL="pc102", XKBLAYOUT="us", XKBVARIANT=""
  305. [ "$XKBLAYOUT" = "" ] && XKBLAYOUT='us'
  306. [ "$XKBMODEL" = "" ] && XKBMODEL='pc102'
  307. sPTN='/./{H;$!d;};x;/Section "InputDevice".*"Keyboard0"/!d'
  308. ASECTION="$(sed "$sPTN" /root/xorg.conf.new | head -n -1)" #leave off EndSection
  309. echo "$ASECTION" >> /tmp/xorg.conf.tmp
  310. echo " Option \"XkbRules\" \"xorg\"
  311. Option \"XkbModel\" \"${XKBMODEL}\"
  312. Option \"XkbLayout\" \"${XKBLAYOUT}\" #xkeymap0" >> /tmp/xorg.conf.tmp
  313. [ "$XKBVARIANT" ] && echo " Option \"XkbVariant\" \"$XKBVARIANT\"" >> /tmp/xorg.conf.tmp
  314. echo -e 'EndSection' >> /tmp/xorg.conf.tmp
  315. ###Mouse###
  316. sPTN='/./{H;$!d;};x;/Section "InputDevice".*"Mouse0"/!d'
  317. ASECTION="$(sed "$sPTN" /root/xorg.conf.new | head -n -1 | grep -v -E 'Emulate3|ZAxisMapping|Protocol')" #leave off EndSection
  318. echo "$ASECTION" >> /tmp/xorg.conf.tmp
  319. case "`cat /etc/mousedevice 2>/dev/null`" in
  320. input/mice) echo ' Option "Protocol" "IMPS/2" #mouse0protocol' >> /tmp/xorg.conf.tmp ;;
  321. *ttyS*) echo ' Option "Protocol" "Microsoft" #mouse0protocol' >> /tmp/xorg.conf.tmp ;;
  322. *) echo ' Option "Protocol" "auto" #mouse0protocol' >> /tmp/xorg.conf.tmp ;;
  323. esac
  324. case "`cat /etc/xextraoptions 2>/dev/null`" in
  325. *2button*)
  326. echo ' Option "Emulate3Buttons"
  327. Option "Emulate3Timeout" "50"' >> /tmp/xorg.conf.tmp
  328. ;;
  329. *)
  330. echo ' #Option "Emulate3Buttons"
  331. #Option "Emulate3Timeout" "50"' >> /tmp/xorg.conf.tmp
  332. ;;
  333. esac
  334. case "`cat /etc/mousebuttons 2>/dev/null`" in
  335. 5) echo ' Option "ZAxisMapping" "4 5" #scrollwheel' >> /tmp/xorg.conf.tmp ;;
  336. *) echo ' #Option "ZAxisMapping" "4 5" #scrollwheel' >> /tmp/xorg.conf.tmp ;;
  337. esac
  338. echo -e 'EndSection' >> /tmp/xorg.conf.tmp
  339. if [ "$FLAGTOUCHPAD" ];then #130428
  340. echo '
  341. Section "InputDevice"
  342. Identifier "SynapticsMouse"
  343. Driver "synaptics"
  344. Option "SHMConfig" "on"
  345. EndSection' >> /tmp/xorg.conf.tmp
  346. fi
  347. ###Monitor###
  348. sPTN='/./{H;$!d;};x;/Section "Monitor".*"Monitor0"/!d'
  349. ASECTION="$(sed "$sPTN" /root/xorg.conf.new | head -n -1 | grep -v -E 'HorizSync|VertRefresh')" #leave off EndSection
  350. echo "$ASECTION" >> /tmp/xorg.conf.tmp
  351. echo " #HorizSync HORIZSYNC0
  352. VertRefresh VERTREFRESH0
  353. #UseModes \"Modes0\" #monitor0usemodes
  354. Option \"PreferredMode\" \"PREFERREDMODE0\"" >> /tmp/xorg.conf.tmp
  355. echo -e 'EndSection\n' >> /tmp/xorg.conf.tmp
  356. echo "Section \"Modes\"
  357. Identifier \"Modes0\"
  358. #modes0modeline0
  359. EndSection" >> /tmp/xorg.conf.tmp
  360. ###Video card###
  361. #130504 peculiar, if nv present, xorg.conf.new does not have nouveau, so add it...
  362. if [ -f /usr/lib/xorg/modules/drivers/nouveau_drv.so ];then
  363. if [ "$(grep 'Driver *"nouveau"' /root/xorg.conf.new)" = "" ];then
  364. if [ "$(grep 'Driver *"nv"' /root/xorg.conf.new)" != "" ];then #130509 fix logic.
  365. echo '
  366. Section "Device"
  367. #Option "SWcursor" # [<bool>]
  368. #Option "HWcursor" # [<bool>]
  369. #Option "NoAccel" # [<bool>]
  370. #Option "ShadowFB" # [<bool>]
  371. #Option "VideoKey" # <i>
  372. #Option "WrappedFB" # [<bool>]
  373. #Option "GLXVBlank" # [<bool>]
  374. #Option "ZaphodHeads" # <str>
  375. #Option "PageFlip" # [<bool>]
  376. #Option "SwapLimit" # <i>
  377. #Option "AsyncUTSDFS" # [<bool>]
  378. Identifier "Card91"
  379. Driver "nouveau"
  380. EndSection
  381. ' >> /root/xorg.conf.new
  382. fi
  383. fi
  384. fi
  385. #or vide-versa...
  386. if [ -f /usr/lib/xorg/modules/drivers/nv_drv.so ];then
  387. if [ "$(grep 'Driver *"nv"' /root/xorg.conf.new)" = "" ];then
  388. if [ "$(grep 'Driver *"nouveau"' /root/xorg.conf.new)" != "" ];then #130509 fix logic.
  389. echo '
  390. Section "Device"
  391. #Option "SWcursor" # [<bool>]
  392. #Option "HWcursor" # [<bool>]
  393. #Option "NoAccel" # [<bool>]
  394. #Option "ShadowFB" # [<bool>]
  395. #Option "UseFBDev" # [<bool>]
  396. #Option "Rotate" # [<str>]
  397. #Option "VideoKey" # <i>
  398. #Option "FlatPanel" # [<bool>]
  399. #Option "FPDither" # [<bool>]
  400. #Option "CrtcNumber" # <i>
  401. #Option "FPScale" # [<bool>]
  402. #Option "FPTweak" # <i>
  403. #Option "DualHead" # [<bool>]
  404. Identifier "Card90"
  405. Driver "nv"
  406. EndSection' >> /root/xorg.conf.new
  407. fi
  408. fi
  409. fi
  410. #130509 unfortunately -configure option does not work very well, i don't think it has been properly
  411. #updated by the developers. I have a pc with sis video, automatic startup loads the sis_drv.so Xorg driver,
  412. #and it works, but -configure does not offer 'sis'. not happy, but will attempt a workaround...
  413. XAUTODRV=''
  414. if [ -f /var/local/quicksetup-pupmode5-autodriver ];then #created in quicksetup.
  415. XAUTODRV="`cat /var/local/quicksetup-pupmode5-autodriver`"
  416. fi
  417. if [ "$XAUTODRV" ];then
  418. if [ -f /usr/lib/xorg/modules/drivers/${XAUTODRV}_drv.so ];then
  419. autoPTN="Driver *\"${XAUTODRV}\""
  420. if [ "$(grep "$autoPTN" /root/xorg.conf.new)" = "" ];then
  421. echo "
  422. Section \"Device\"
  423. Identifier \"Card92\"
  424. Driver \"${XAUTODRV}\"
  425. EndSection" >> /root/xorg.conf.new
  426. fi
  427. fi
  428. fi
  429. #130523 when proprietary nvidia driver installed, xorgwizard-cli does not offer it,
  430. #only offers nouvea, modesetting and vesa. note, the official installer offers to
  431. #blacklist nouvea kernel module in /etc/modprobe.d, however in case that is not done...
  432. if [ -f /usr/lib/xorg/modules/drivers/nvidia_drv.so ];then
  433. if [ "$(grep 'Driver *"nvidia"' /root/xorg.conf.new)" = "" ];then
  434. if [ "$(grep 'Driver *"nouveau"' /root/xorg.conf.new)" != "" ];then
  435. echo '
  436. Section "Device"
  437. Identifier "Card93"
  438. Driver "nvidia"
  439. EndSection' >> /root/xorg.conf.new
  440. fi
  441. fi
  442. fi
  443. #how do we handle all the card sections? ...
  444. echo -n "" > /tmp/xorgwizard-driverlist0
  445. for CARDNUM in 0 1 2 3 4 5 6 90 91 92 93
  446. do
  447. sPTN='/./{H;$!d;};x;/Section "Device".*"Card'${CARDNUM}'"/!d'
  448. ASECTION="$(sed "$sPTN" /root/xorg.conf.new | head -n -1)" #leave off EndSection
  449. [ ! "$ASECTION" ] && continue
  450. #create a list and offer choice to user...
  451. XORGDRIVER="$(echo "$ASECTION" | grep -E '^\W+Driver' | cut -f 2 -d '"')" #'geany
  452. [ ! -f /usr/lib/xorg/modules/drivers/${XORGDRIVER}_drv.so ] && continue
  453. EXMSG='driver'; EX2MSG=''
  454. MSGKMS="$(gettext 'driver, needs KMS')"
  455. MSGNOKMS="$(gettext 'driver, no KMS')"
  456. MSGREBOOT="$(gettext '(requires reboot)')"
  457. MSGUNACCEL="$(gettext 'Unaccelerated driver')"
  458. case $XORGDRIVER in
  459. vesa)
  460. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  461. EXMSG="${MSGUNACCEL}"
  462. ;;
  463. nouveau)
  464. [ "$ACTIVE_KMS_PTN" != "010" ] && EX2MSG=" ${MSGREBOOT}"
  465. EXMSG="NVIDIA ${MSGKMS}"
  466. ;;
  467. nv)
  468. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  469. EXMSG="$(gettext 'Simple NVIDA driver')"
  470. ;;
  471. nvidia)
  472. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  473. EXMSG="$(gettext 'NVIDIA proprietary driver')"
  474. ;;
  475. modesetting)
  476. #i think requires all of the kernel kms drivers enabled...
  477. [ "$KMS_all" != "111" ] && EX2MSG=" ${MSGREBOOT}"
  478. EXMSG="${MSGUNACCEL}"
  479. ;;
  480. intel)
  481. [ "$ACTIVE_KMS_PTN" != "100" ] && EX2MSG=" ${MSGREBOOT}"
  482. EXMSG="Intel ${MSGKMS}"
  483. ;;
  484. radeon)
  485. [ "$ACTIVE_KMS_PTN" != "001" ] && EX2MSG=" ${MSGREBOOT}"
  486. EXMSG="ATI Radeon ${MSGKMS}"
  487. ;;
  488. radeonhd) #old abandoned radeon non-kms driver.
  489. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  490. EXMSG="$(gettext 'Old ATI Radeon driver')"
  491. ;;
  492. ati|mach64|r128)
  493. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  494. EXMSG="ATI ${MSGNOKMS}"
  495. ;;
  496. fglrx) #does not work with kms...
  497. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  498. EXMSG="$(gettext 'ATI proprietary driver')"
  499. ;;
  500. fbdev) continue ;;
  501. *)
  502. [ "$ACTIVE_KMS_PTN" != "000" ] && EX2MSG=" ${MSGREBOOT}"
  503. ;;
  504. esac
  505. echo "$CARDNUM $XORGDRIVER \"${EXMSG}${EX2MSG}\"" >> /tmp/xorgwizard-driverlist0
  506. done
  507. DRIVERLIST="$(sort --key=2,2 --unique /tmp/xorgwizard-driverlist0 | cut -f 2- -d ' ' | tr '\n' ' ')"
  508. #130504 customise driver help dlg...
  509. ACCELDRVHELP="$(gettext 'Accelerated drivers are designed for specific video hardware. Basically, they are much faster than the unaccelerated drivers. They may also offer additional configuration features.')"
  510. DRVCHOICES="$(cut -f 2 -d ' ' /tmp/xorgwizard-driverlist0 | tr '\n' ' ')"
  511. case "$DRVCHOICES" in
  512. *nv*|*nouveau*|*nvidia*) #note \Z7 is reverse text, \Zn returns to normal...
  513. ACCELDRVHELP="${ACCELDRVHELP}
  514. \Z7NVIDIA\Zn
  515. nv: $(gettext 'This is the simplest accelerated driver. Works without KMS')
  516. nouveau: $(gettext 'Most sophisticated accelerated driver. Requires KMS')
  517. nvidia: $(gettext 'If installed, this is the commercial driver. Works without KMS')"
  518. ;;
  519. esac
  520. case "$DRVCHOICES" in
  521. *intel*|*i810*)
  522. ACCELDRVHELP="${ACCELDRVHELP}
  523. \Z7Intel\Zn
  524. intel: $(gettext 'Intel accelerated driver. Requires KMS')
  525. i810: $(gettext 'If installed, for some older hardware. Works without KMS')"
  526. ;;
  527. esac
  528. case "$DRVCHOICES" in
  529. *ati*|*r128*|*mach64*|*radeon*|*fglrx*)
  530. ACCELDRVHELP="${ACCELDRVHELP}
  531. \Z7ATI\Zn
  532. r128: mach64: $(gettext 'These are accelerated drivers for certain ATI hardware.')
  533. radeon: $(gettext 'Accelerated driver for ATI Radeon hardware. Requires KMS')
  534. radeonhd: $(gettext 'If installed, older accelerated driver. Without KMS')
  535. fglrx: $(gettext 'If installed, accelerated commercial driver. Without KMS')"
  536. ;;
  537. esac
  538. DRVDLGMSG="$(gettext 'Please use UP/DOWN arrow keys to choose a Xorg driver, then press ENTER key...')
  539. $(gettext 'Or, press TAB (or RIGHT arrow) then ENTER to exit from the Wizard...')
  540. $(gettext 'If uncertain, press TAB, TAB then ENTER to choose <Help>...')"
  541. echo '#!/bin/sh' > /tmp/xorgwizard-driverlist-choose.sh
  542. echo "dialog --stdout --title \"${DLGTITLE}\" --help-button --help-label "$(gettext 'Help')" --menu \"${DRVDLGMSG}\" 0 0 0 ${DRIVERLIST}" >> /tmp/xorgwizard-driverlist-choose.sh
  543. echo 'exit $?' >> /tmp/xorgwizard-driverlist-choose.sh
  544. chmod 755 /tmp/xorgwizard-driverlist-choose.sh
  545. while [ 1 -eq 1 ];do
  546. xCHOSENDRV="`/tmp/xorgwizard-driverlist-choose.sh 2>/dev/null`"
  547. RETVAL=$?
  548. CHOSENDRV="`echo -n "$xCHOSENDRV" | cut -f 1 -d '_'`" #get rid of _NOKMS
  549. case $RETVAL in
  550. 0) break ;;
  551. 2) #help
  552. dialog --colors --no-cancel --title "${DLGTITLE}: $(gettext 'Help')" --msgbox "$(gettext 'The Xorg Wizard has probed the computer and determined that any of these drivers may be suitable. Choose that which seems most appropriate. If a driver does not work, at worst even hangs the PC, you will be able to re-run the Wizard and choose another driver.')
  553. ${ACCELDRVHELP}
  554. \Z7$(gettext 'Generic')\Zn
  555. $(gettext "Fallbacks are the generic unaccelerated drivers 'vesa' and 'modesetting', that should work for all video hardware. They have limitations, such as slowness and no full-screen video. The 'vesa' driver can only use a VESA standard resolution (which may not match your wide-screen monitor), however the 'modesetting' driver can be set to the native resolution of the monitor.")" 0 0
  556. continue
  557. ;;
  558. *) exit ;; #maybe pressed esc key.
  559. esac
  560. done
  561. #write chosen card section to xorg.conf...
  562. CARDNUM="$(cut -f 1 -d '"' /tmp/xorgwizard-driverlist0 | grep -w "$CHOSENDRV" | head -n 1 | cut -f 1 -d ' ')" #'geany
  563. sPTN='/./{H;$!d;};x;/Section "Device".*"Card'${CARDNUM}'"/!d'
  564. ASECTION="$(sed "$sPTN" /root/xorg.conf.new | head -n -1 | grep -v -E 'BusID|Identifier|Driver')" #leave off EndSection
  565. echo "$ASECTION" >> /tmp/xorg.conf.tmp
  566. echo ' Identifier "Card0"' >> /tmp/xorg.conf.tmp
  567. echo ' Driver "'"${CHOSENDRV}"'" #card0driver' >> /tmp/xorg.conf.tmp
  568. echo -e 'EndSection\n' >> /tmp/xorg.conf.tmp
  569. ###Screen section###
  570. HORIZSYNC=""; VERTREFRESH=""; MONCHOICES=""
  571. #modes supported by monitor... format of each line: 1024x768@75
  572. if [ "$CHOSENDRV" != "vesa" ];then
  573. MONXY0="$(grep '^dtiming:' /tmp/ddcprobe.txt | cut -f 2 -d ' ' | cut -f 1 -d '@' | sed -e 's%$% "Recommended choice"%')"
  574. #get too many weird resolutions, maybe better just only allow these...
  575. MONXY1="$(grep '^timing:' /tmp/ddcprobe.txt | grep -E -v 'Apple|8514A|Mac II|\(XGA2\)' | grep -E ' 640x480@| 800x480@| 800x600@| 1024x600@| 1024x768@| 1280x768@| 1280x800@| 1280x1024@| 1366x768@| 1400x1050@| 1440x900@| 1600x900@| 1600x1200@| 1680x1050@| 1920x1080@| 1920x1200@' | cut -f 2 -d ' ' | cut -f 1 -d '@' | sed -e 's%$% "Resolution supported by monitor"%')"
  576. fi
  577. MONXY2="$(grep '^mode:' /tmp/ddcprobe.txt | cut -f 2 -d ' ' | cut -f 1,2 -d 'x' | sed -e 's%$% "VESA standard resolution"%')"
  578. MONXY3="$(echo -e '800x600\n1024x768\n1280x1024' | sed -e 's%$% "VESA standard resolution"%')"
  579. XYCHOICES="$(echo -e "${MONXY0}\n${MONXY2}\n${MONXY1}\n${MONXY3}" | sed -e 's%^$%%' | sort --field-separator=x --key=1,1 --unique --numeric-sort | tr '\n' ' ')"
  580. #dialog to offer resolutions... 130504 add 'NOTHING' option...
  581. XGUESS="$(gettext 'Let Xorg guess it')"
  582. RESDLGMSG="$(gettext "Screen resolutions are listed below, in the format horizontal x vertical pixels. One of these will be best suited to your monitor. If the Wizard offers a 'recommended' resolution, choose that.")
  583. NOTHING: $(gettext 'This option means leave it up to Xorg to try and guess the most appropriate resolution -- this usually works well.')
  584. $(gettext 'Use the UP/DOWN arrow keys to choose a resolution, then press ENTER key...')
  585. $(gettext 'Or, press TAB then ENTER for more resolutions to choose from...')"
  586. echo '#!/bin/sh' > /tmp/xorgwizard-resolution.sh
  587. echo "dialog --stdout --title \"${DLGTITLE}\" --ok-label \"$(gettext 'OK')\" --cancel-label \"$(gettext 'More')\" --menu \"${RESDLGMSG}\" 0 0 0 ${XYCHOICES} NOTHING \"${XGUESS}\"" >> /tmp/xorgwizard-resolution.sh
  588. echo 'exit $?' >> /tmp/xorgwizard-resolution.sh
  589. chmod 755 /tmp/xorgwizard-resolution.sh
  590. while true ; do #130504 second dlg with more choices...
  591. FINALXY="$(/tmp/xorgwizard-resolution.sh)"
  592. RESRET=$?
  593. [ $RESRET -ne 0 -a $RESRET -ne 1 ] && exit
  594. if [ $RESRET -eq 1 ];then #More
  595. RESHI="$(gettext 'Hi-res monitor')"
  596. RESVHI="$(gettext 'Very hi-res monitor')"
  597. RESNONV="$(gettext 'Non-VESA, widescreen')"
  598. MOREDLG="$(gettext 'Use the UP/DOWN arrow keys to choose a resolution, then press ENTER key...')
  599. $(gettext 'Or, press TAB then ENTER to go back to previous window...')"
  600. FINALXY="`dialog --stdout --title "${DLGTITLE}" --ok-label "$(gettext 'OK')" --cancel-label "$(gettext 'Go back')" --menu "${MOREDLG}" 0 0 0 640x480 "$(gettext 'Very poor, not usable')" 800x600 "$(gettext 'Minimum usable by Puppy')" 1024x600 "." 1024x768 "$(gettext 'Good, works with most monitors')" 1280x800 "${RESNONV}" 1280x1024 "${RESHI}" 1366x768 "${RESNONV}" 1400x1050 "${RESHI}" 1440x900 "${RESNONV}" 1600x900 "${RESNONV}" 1600x1200 "${RESVHI}" 1680x1050 "${RESVHI}" 1920x1080 "${RESVHI}" 1920x1200 "${RESVHI}"`"
  601. [ $? -ne 0 ] && continue
  602. fi
  603. break
  604. done
  605. MONFREQ="`grep -F 'monitorrange:' /tmp/ddcprobe.txt | cut -f 2-10 -d ' '`"
  606. if [ "$MONFREQ" ];then
  607. HORIZSYNC="`echo -n "$MONFREQ" | cut -f 1 -d ','`"
  608. VERTREFRESH="`echo -n "$MONFREQ" | cut -f 2 -d ',' | tr -d ' '`"
  609. #130503 my "white tower" with crt monitor: "monitorrange: 30-95, 50-160"
  610. #however, previous experience is that the upper limit of 160 is too high...
  611. #i don't think much of 50 either...
  612. if [ "$(echo -n "$VERTREFRESH" | grep '\-')" != "" ];then
  613. LOWERLIMIT="$(echo -n "$VERTREFRESH" | cut -f 1 -d '-')"
  614. UPPERLIMIT="$(echo -n "$VERTREFRESH" | cut -f 2 -d '-')"
  615. if vercmp $LOWERLIMIT lt 59; then LOWERLIMIT="59" ; fi #use vercmp in case of decimal point.
  616. if vercmp $UPPERLIMIT gt 86; then UPPERLIMIT="86" ; fi
  617. VERTREFRESH="${LOWERLIMIT}-${UPPERLIMIT}"
  618. fi
  619. fi
  620. FINALDEPTH="24"
  621. [ ! "$FINALXY" ] && FINALXY="1024x768"
  622. [ ! "$HORIZSYNC" ] && HORIZSYNC="31-50"
  623. [ ! "$VERTREFRESH" ] && VERTREFRESH="59-76"
  624. echo "Section \"Screen\"
  625. Identifier \"Screen0\"
  626. Device \"Card0\"
  627. Monitor \"Monitor0\"
  628. DefaultDepth $FINALDEPTH
  629. #Option \"metamodes\" \"PREFERREDMODE0_60 +0+0\" #METAMODES_0
  630. Subsection \"Display\"
  631. Depth $FINALDEPTH
  632. Modes \"PREFERREDMODE0\"
  633. EndSubsection
  634. EndSection
  635. " >> /tmp/xorg.conf.tmp
  636. #fixups...
  637. if [ "$FINALXY" = "NOTHING" ];then #130504
  638. sed -i -e "s/HORIZSYNC0/$HORIZSYNC/ ; s/VERTREFRESH0/$VERTREFRESH/" /tmp/xorg.conf.tmp
  639. sed -i -r -e 's%(.*PREFERREDMODE0.*)%#\1%' /tmp/xorg.conf.tmp #comment-out those lines.
  640. sed -i -e 's%PREFERREDMODE0%1024x768%' /tmp/xorg.conf.tmp #better insert a resolution.
  641. else
  642. PREFERREDMODE=$FINALXY #set monitor preferred mode same as screen mode.
  643. sed -i -e "s/HORIZSYNC0/$HORIZSYNC/ ; s/VERTREFRESH0/$VERTREFRESH/ ; s/PREFERREDMODE0/$PREFERREDMODE/" /tmp/xorg.conf.tmp
  644. fi
  645. #want a hardware profile so can bootup on different PCs...
  646. PROFILECHIP="`grep -m1 '^oem: ' /tmp/ddcprobe.txt | cut -f 2-4 -d ' ' | tr ' ' '_' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  647. #'eisa:' and 'id:' return fluctuating values on some PCs, so search in this order...
  648. PROFILEMONITOR="`grep '^monitorid: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  649. [ "$PROFILEMONITOR" = "" ] && PROFILEMONITOR="`grep '^monitorname: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  650. [ "$PROFILEMONITOR" = "" ] && PROFILEMONITOR="`grep '^monitorrange: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  651. echo "#PuppyHardwareProfile=${PROFILECHIP}${PROFILEMONITOR}" >> /tmp/xorg.conf.tmp
  652. if [ -f /etc/X11/xorg.conf ];then #130506
  653. YMDHM="$(stat -c %y /etc/X11/xorg.conf | cut -f 1,2 -d ':' | tr '[ :]' '-')"
  654. cp -f /etc/X11/xorg.conf /etc/X11/xorg.conf-BACKUP-${YMDHM}
  655. fi
  656. cp -f /tmp/xorg.conf.tmp /etc/X11/xorg.conf
  657. #create a copy of xorg.conf with the profile in the filename...
  658. cp -af /etc/X11/xorg.conf /etc/X11/xorg.conf.${PROFILECHIP}${PROFILEMONITOR}
  659. mv -f /root/xorg.conf.new /tmp/xorg.conf.new #130429 130503
  660. #do we need to reboot?
  661. REBOOT_RQD=0
  662. case $CHOSENDRV in
  663. vesa)
  664. if [ "$ACTIVE_KMS_PTN" != "000" ];then
  665. #reboot is required.
  666. [ "$ACTIVE_KMS_i915" = "1" ] && echo 'options i915 modeset=0' > /etc/modprobe.d/i915.conf
  667. [ "$ACTIVE_KMS_nouveau" = "1" ] && echo 'options nouveau modeset=0' > /etc/modprobe.d/nouveau.conf
  668. [ "$ACTIVE_KMS_radeon" = "1" ] && echo 'options radeon modeset=0' > /etc/modprobe.d/radeon.conf
  669. REBOOT_RQD=1
  670. fi
  671. ;;
  672. modesetting)
  673. #don't know about this... ??????
  674. if [ "$KMS_all" != "111" ]; then
  675. [ "$ACTIVE_KMS_i915" = "0" ] && echo 'options i915 modeset=1' > /etc/modprobe.d/i915.conf
  676. [ "$ACTIVE_KMS_nouveau" = "0" ] && echo 'options nouveau modeset=1' > /etc/modprobe.d/nouveau.conf
  677. [ "$ACTIVE_KMS_radeon" = "0" ] && echo 'options radeon modeset=1' > /etc/modprobe.d/radeon.conf
  678. REBOOT_RQD=1
  679. fi
  680. ;;
  681. intel)
  682. if [ "$ACTIVE_KMS_PTN" != "100" ];then #active intel kms only
  683. [ "$ACTIVE_KMS_i915" = "0" ] && echo 'options i915 modeset=1' > /etc/modprobe.d/i915.conf
  684. [ "$ACTIVE_KMS_nouveau" = "1" ] && echo 'options nouveau modeset=0' > /etc/modprobe.d/nouveau.conf
  685. [ "$ACTIVE_KMS_radeon" = "1" ] && echo 'options radeon modeset=0' > /etc/modprobe.d/radeon.conf
  686. REBOOT_RQD=1
  687. fi
  688. ;;
  689. nouveau)
  690. if [ "$ACTIVE_KMS_PTN" != "010" ];then
  691. [ "$ACTIVE_KMS_i915" = "1" ] && echo 'options i915 modeset=0' > /etc/modprobe.d/i915.conf
  692. [ "$ACTIVE_KMS_nouveau" = "0" ] && echo 'options nouveau modeset=1' > /etc/modprobe.d/nouveau.conf
  693. [ "$ACTIVE_KMS_radeon" = "1" ] && echo 'options radeon modeset=0' > /etc/modprobe.d/radeon.conf
  694. REBOOT_RQD=1
  695. fi
  696. ;;
  697. nv)
  698. if [ "$ACTIVE_KMS_PTN" != "000" ];then
  699. [ "$ACTIVE_KMS_i915" = "1" ] && echo 'options i915 modeset=0' > /etc/modprobe.d/i915.conf
  700. [ "$ACTIVE_KMS_nouveau" = "1" ] && echo 'options nouveau modeset=0' > /etc/modprobe.d/nouveau.conf
  701. [ "$ACTIVE_KMS_radeon" = "1" ] && echo 'options radeon modeset=0' > /etc/modprobe.d/radeon.conf
  702. REBOOT_RQD=1
  703. fi
  704. ;;
  705. radeon)
  706. if [ "$ACTIVE_KMS_PTN" != "001" ];then
  707. [ "$ACTIVE_KMS_i915" = "1" ] && echo 'options i915 modeset=0' > /etc/modprobe.d/i915.conf
  708. [ "$ACTIVE_KMS_nouveau" = "1" ] && echo 'options nouveau modeset=0' > /etc/modprobe.d/nouveau.conf
  709. [ "$ACTIVE_KMS_radeon" = "0" ] && echo 'options radeon modeset=1' > /etc/modprobe.d/radeon.conf
  710. REBOOT_RQD=1
  711. fi
  712. ;;
  713. *) #all other drivers.
  714. if [ "$ACTIVE_KMS_PTN" != "000" ];then
  715. [ "$ACTIVE_KMS_i915" = "1" ] && echo 'options i915 modeset=0' > /etc/modprobe.d/i915.conf
  716. [ "$ACTIVE_KMS_nouveau" = "1" ] && echo 'options nouveau modeset=0' > /etc/modprobe.d/nouveau.conf
  717. [ "$ACTIVE_KMS_radeon" = "1" ] && echo 'options radeon modeset=0' > /etc/modprobe.d/radeon.conf
  718. REBOOT_RQD=1
  719. fi
  720. ;;
  721. esac
  722. echo "$CHOSENDRV" > /root/.xorgwizard-reenter
  723. EX3MSG=''
  724. if [ $REBOOT_RQD -eq 1 ];then
  725. [ $PUPMODE -eq 5 ] && EX3MSG="$(gettext 'IMPORTANT: At shutdown you will be asked to create a session save-file, please do so.')"
  726. dialog --title "${DLGTITLE}" --msgbox "$(eval_gettext "A reboot is required before the '\${CHOSENDRV}' driver can be tested.")
  727. ${EX3MSG}
  728. $(gettext 'Click <OK> button to reboot...')" 0 0
  729. #note: /root/.profile sees existence of /root/.xorgwizard-reenter and runs xorgwizard-cli instead of xwin (which starts X).
  730. sync
  731. exec reboot ###EXIT###
  732. fi
  733. #reenter this script...
  734. exec xorgwizard-cli