xorgwizard-automatic 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #!/bin/sh
  2. #(c) copyright Barry Kauler 2011, bkhome.org
  3. #2011 GPL licence v3 (/usr/share/doc/legal/gpl-3.0.htm)
  4. #called from /usr/bin/xwin.
  5. #20110404 first version.
  6. #110627 slight mod. see also /etc/X11/xorg.conf-auto-pc
  7. #110701 synaptics stuff seems to clash with xorg-server 1.10.1.
  8. #110727 ddcprobe segfaults on my new laptop.
  9. #110912 fix syntax error. Message at exit of script.
  10. #110913 ddcprobe working new laptop latest wary with xorg7.6. fix 1366x768 resolution. fix touchpad.
  11. #120129 jemimah: add Option "SHMConfig" "on".
  12. #120329 correctly set keyboard layout, model and variant.
  13. #120517 arm builds do not work with ddcprobe. for now, just execute some basic code for arm systems.
  14. . /etc/rc.d/MODULESCONFIG
  15. #120517
  16. if [ "`which ddcprobe`" = "" ];then
  17. #running on an arm board...
  18. cp -f /etc/X11/xorg.conf-auto-armsystem /etc/X11/xorg.conf
  19. echo "#PuppyHardwareProfile=armsystem" >> /etc/X11/xorg.conf
  20. #create a copy of xorg.conf with the profile in the filename...
  21. cp -af /etc/X11/xorg.conf /etc/X11/xorg.conf.armsystem
  22. echo
  23. echo "Xorg Wizard Automatic has just run."
  24. echo "If you are reading this, then you are at the console without X running."
  25. echo "The usual thing now is to type 'xwin' to start X..."
  26. exit ###EXIT###
  27. fi
  28. #110701
  29. XORGVER="`Xorg -version 2>&1 | grep '^X\.Org' | rev | cut -f 1 -d ' ' | rev`"
  30. [ ! "$XORGVER" ] && XORGVER="1.3" #110913 precaution.
  31. RETVALS="`keymap-set --xopt`"
  32. eval "$RETVALS" #ex: XKBMODEL="pc102", XKBLAYOUT="us", XKBVARIANT=""
  33. [ "$XKBLAYOUT" = "" ] && XKBLAYOUT='us'
  34. [ "$XKBMODEL" = "" ] && XKBMODEL='pc102'
  35. #probe monitor...
  36. ddcprobe >/tmp/ddcprobe.txt
  37. #weird (ddcprobe is very weird), on some hardware, probe fails every alternate run of ddcprobe...
  38. case "`cat /tmp/ddcprobe.txt`" in *edidfail*)
  39. sleep 1
  40. ddcprobe >/tmp/ddcprobe.txt
  41. ;;
  42. esac
  43. case "`cat /tmp/ddcprobe.txt`" in *edidfail*)
  44. sleep 1
  45. ddcprobe >/tmp/ddcprobe.txt
  46. ;;
  47. esac
  48. CHOSENRES=''
  49. if [ -s /tmp/ddcprobe.txt ];then #110727 ddcprobe segfaults on my new laptop.
  50. #the vesa 'mode:' lines returned by ddcprobe are very limited...
  51. XMODES="`grep '^mode:' /tmp/ddcprobe.txt | grep -E 'x64k|x16m'| cut -f 2 -d ' ' | sed -e 's/x64k/x16/g ; s/x16m/x24/g' | sort -u -g`"
  52. echo "$XMODES" > /tmp/Xmodes.txt
  53. MONCHOICES="`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 ' ' | sort -u -g`" #ex: 1280x800@59
  54. cMONCHOICES="`grep '^ctiming:' /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 ' ' | sort -u -g`" #ex: 1280x800@59
  55. dMONCHOICES="`grep '^dtiming:' /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 ' ' | sort -u -g`" #ex: 1280x800@59
  56. xMONCHOICES="$MONCHOICES"
  57. [ "$cMONCHOICES" ] && xMONCHOICES="$cMONCHOICES"
  58. [ "$dMONCHOICES" ] && xMONCHOICES="$dMONCHOICES"
  59. [ ! "$xMONCHOICES" ] && xMONCHOICES="`echo "$XMODES" | grep '1024x768'`" #fallback. 110912 syntax error.
  60. if [ "$xMONCHOICES" ];then
  61. CHOSENRES="`echo -n "$xMONCHOICES" | tail -n 1 | cut -f 1 -d '@'`"
  62. #patch video bios resolution for widescreen...
  63. if grep -F 'oem:' /tmp/ddcprobe.txt | grep -F -q 'Intel' ;then
  64. MYXYRES="`echo -n "$CHOSENRES" | cut -f 1-2 -d 'x'`"
  65. if ! grep -q "$MYXYRES" /tmp/Xmodes.txt ;then
  66. MYXRES="`echo -n "$CHOSENRES" | cut -f 1 -d 'x'`"
  67. MYYRES="`echo -n "$CHOSENRES" | cut -f 2 -d 'x'`"
  68. #this is an app that patches video-bios, but in ram only...
  69. 915resolution 38 $MYXRES $MYYRES #...replaces mode 38 (1024x768).
  70. #create something for xwin to execute... actually, executing this in /etc/profile...
  71. echo "915resolution 38 $MYXRES $MYYRES" > /etc/resolutionfix
  72. fi
  73. else
  74. #in case plug usb or multisession-cd into different pc...
  75. [ -f /etc/resolutionfix ] && rm -f /etc/resolutionfix
  76. fi
  77. fi
  78. fi
  79. cp -f /etc/X11/xorg.conf-auto-pc /etc/X11/xorg.conf
  80. #120329
  81. REGEX4="s%.*#xkeymap0% Option \"XkbLayout\" \"${XKBLAYOUT}\" #xkeymap0%"
  82. REGEX5="s%.*#xkbmodel0% Option \"XkbModel\" \"${XKBMODEL}\" #xkbmodel0%"
  83. sed -i -e "$REGEX4" -e "$REGEX5" /etc/X11/xorg.conf
  84. if [ "$XKBVARIANT" ];then
  85. REGEX6="s%.*#xkbvariant0% Option \"XkbVariant\" \"${XKBVARIANT}\" #xkbvariant0%"
  86. sed -i -e "$REGEX6" /etc/X11/xorg.conf
  87. fi
  88. if [ "$CHOSENRES" ];then
  89. REGEX1="s%.*#screen0modes% Modes \"${CHOSENRES}\" #screen0modes%"
  90. REGEX2="s%.*#monitor0prefmode% Option \"PreferredMode\" \"${CHOSENRES}\" #monitor0prefmode%"
  91. sed -i -e "$REGEX1" -e "$REGEX2" /etc/X11/xorg.conf
  92. fi
  93. TOUCHPAD=''; OLD3='Section "Monitor"'
  94. [ "`grep 'Elantech' /proc/bus/input/devices`" ] && TOUCHPAD='Elantech'
  95. [ "`grep 'Alps' /proc/bus/input/devices`" ] && TOUCHPAD='Alps'
  96. [ "`grep 'Synaptics' /proc/bus/input/devices`" ] && TOUCHPAD='Synaptics'
  97. if [ "$TOUCHPAD" ];then
  98. if [ "`lsmod | grep '^evdev'`" = "" ];then
  99. REGEXt0="s%^ADDLIST=.*%ADDLIST='${ADDLIST} evdev '%"
  100. sed -i -e "$REGEXt0" /etc/rc.d/MODULESCONFIG #so evdev module will load next bootup.
  101. modprobe evdev
  102. fi
  103. if vercmp $XORGVER lt 1.9.0; then #110701
  104. REGEXt1='s%.*#loadsynaptics% Load "synaptics" #loadsynaptics%'
  105. REGEXt2='s%.*#serverlayoutsynaptics% InputDevice "Synaptics Mouse" "AlwaysCore" #serverlayoutsynaptics%'
  106. sed -i -e "$REGEXt1" -e "$REGEXt2" /etc/X11/xorg.conf
  107. case $TOUCHPAD in
  108. Elantech) #jemimah
  109. NEW3='Section "InputDevice"\
  110. Identifier "Synaptics Mouse"\
  111. Driver "synaptics"\
  112. Option "Device" "/dev/psaux"\
  113. Option "Protocol" "auto-dev"\
  114. Option "LeftEdge" "60"\
  115. Option "RightEdge" "1070"\
  116. Option "TopEdge" "90"\
  117. Option "BottomEdge" "680"\
  118. Option "Emulate3Buttons" "on"\
  119. Option "MaxTapTime" "180"\
  120. Option "MaxTapMove" "59"\
  121. Option "VertScrollDelta" "20"\
  122. Option "MinSpeed" "0.75"\
  123. Option "MaxSpeed" "1.00"\
  124. Option "AccelFactor" "0.16"\
  125. Option "SHMConfig" "on"\
  126. Option "VertEdgeScroll" "on"\
  127. Option "TapButton1" "1"\
  128. EndSection\
  129. \
  130. Section "Monitor"'
  131. ;;
  132. Alps) #kirk
  133. NEW3='Section "InputDevice"\
  134. Identifier "Synaptics Mouse"\
  135. Driver "synaptics"\
  136. Option "Device" "/dev/psaux"\
  137. Option "Protocol" "auto-dev"\
  138. Option "LeftEdge" "120"\
  139. Option "RightEdge" "930"\
  140. Option "TopEdge" "120"\
  141. Option "BottomEdge" "650"\
  142. Option "FingerLow" "14"\
  143. Option "FingerHigh" "15"\
  144. Option "MaxTapTime" "0"\
  145. Option "MaxTapMove" "110"\
  146. Option "VertScrollDelta" "20"\
  147. Option "MinSpeed" "0.3"\
  148. Option "MaxSpeed" "0.75"\
  149. Option "AccelFactor" "0.030"\
  150. Option "EdgeMotionMinSpeed" "200"\
  151. Option "EdgeMotionMaxSpeed" "200"\
  152. Option "UpDownScrolling" "1"\
  153. Option "CircularScrolling" "1"\
  154. Option "CircScrollDelta" "0.1"\
  155. Option "CircScrollTrigger" "2"\
  156. Option "SHMConfig" "on"\
  157. EndSection\
  158. \
  159. Section "Monitor"'
  160. ;;
  161. Synaptics)
  162. NEW3='Section "InputDevice"\
  163. Identifier "Synaptics Mouse"\
  164. Driver "synaptics"\
  165. Option "Device" "/dev/psaux"\
  166. Option "Protocol" "auto-dev"\
  167. Option "LeftEdge" "1700"\
  168. Option "RightEdge" "5300"\
  169. Option "TopEdge" "1700"\
  170. Option "BottomEdge" "4200"\
  171. Option "FingerLow" "25"\
  172. Option "FingerHigh" "30"\
  173. Option "MaxTapTime" "0"\
  174. Option "MaxTapMove" "220"\
  175. Option "VertScrollDelta" "100"\
  176. Option "MinSpeed" "0.10"\
  177. Option "MaxSpeed" "0.30"\
  178. Option "AccelFactor" "0.0030"\
  179. Option "SHMConfig" "on"\
  180. #Option "Repeater" "/dev/ps2mouse"\
  181. EndSection\
  182. \
  183. Section "Monitor"'
  184. ;;
  185. esac
  186. sed -i -e "s%${OLD3}%${NEW3}%" /etc/X11/xorg.conf
  187. else
  188. #110913 create basic section...
  189. #120129 jemimah: add Option "SHMConfig" "on"...
  190. REGEXt1='s%.*#loadsynaptics% Load "synaptics" #loadsynaptics%'
  191. REGEXt2='s%.*#serverlayoutsynaptics% InputDevice "Synaptics Mouse" "AlwaysCore" #serverlayoutsynaptics%'
  192. NEW3='Section "InputDevice"\
  193. Identifier "Synaptics Mouse"\
  194. Driver "synaptics"\
  195. Option "SHMConfig" "on"\
  196. EndSection\
  197. \
  198. Section "Monitor"'
  199. REGEXt3="s%${OLD3}%${NEW3}%"
  200. sed -i -e "$REGEXt1" -e "$REGEXt2" -e "$REGEXt3" /etc/X11/xorg.conf
  201. fi #110701 endif
  202. fi
  203. #want a hardware profile so can bootup on different PCs...
  204. PROFILECHIP="`grep -m1 '^oem: ' /tmp/ddcprobe.txt | cut -f 2-4 -d ' ' | tr ' ' '_' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  205. #'eisa:' and 'id:' return fluctuating values on some PCs, so search in this order...
  206. PROFILEMONITOR="`grep '^monitorid: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  207. [ "$PROFILEMONITOR" = "" ] && PROFILEMONITOR="`grep '^monitorname: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  208. [ "$PROFILEMONITOR" = "" ] && PROFILEMONITOR="`grep '^monitorrange: ' /tmp/ddcprobe.txt | head -n 1 | cut -f 2 -d ':' | tr -d ' ' | sed -e 's/[^0-9a-zA-Z]/_/g'`"
  209. echo "#PuppyHardwareProfile=${PROFILECHIP}${PROFILEMONITOR}" >> /etc/X11/xorg.conf
  210. #create a copy of xorg.conf with the profile in the filename...
  211. cp -af /etc/X11/xorg.conf /etc/X11/xorg.conf.${PROFILECHIP}${PROFILEMONITOR}
  212. echo
  213. echo "Xorg Wizard Automatic has just run."
  214. echo "If you are reading this, then you are at the console without X running."
  215. echo "The usual thing now is to type 'xwin' to start X..."
  216. ###END###