Contents of /alx-src/branches/alxconf-060/functions/config_x11.sh
Parent Directory | Revision Log
Revision 1653 -
(show annotations)
(download)
(as text)
Sat Jan 22 17:57:19 2011 UTC (13 years, 8 months ago) by niro
Original Path: alx-src/branches/alxconf_20060908/functions/config_x11.sh
File MIME type: application/x-sh
File size: 10275 byte(s)
Sat Jan 22 17:57:19 2011 UTC (13 years, 8 months ago) by niro
Original Path: alx-src/branches/alxconf_20060908/functions/config_x11.sh
File MIME type: application/x-sh
File size: 10275 byte(s)
-fallback to sane refresh timings if EDID of the monitor returns zero rates
1 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_x11.sh,v 1.9 2005-10-09 21:31:54 niro Exp $ |
2 | # configures the x11 server on the host via mysql db settings |
3 | |
4 | get_x11_settings() |
5 | { |
6 | local x i all DB_X11SETTINGS |
7 | # autodetect |
8 | all=$(mysqldo "select module, |
9 | resolution, |
10 | depth, |
11 | refresh_rate |
12 | from cfg_graphic where serial='${ALX_SERIAL}'") |
13 | |
14 | # split'em up and put 'em in an array |
15 | declare -i i=0 |
16 | for x in ${all} |
17 | do |
18 | DB_X11SETTINGS[${i}]="${x}" |
19 | ((i++)) |
20 | done |
21 | |
22 | # and now put them in usable var names and export them systemwide |
23 | export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}" |
24 | export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}" |
25 | export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}" |
26 | export ALX_REFRESH_RATE="${DB_X11SETTINGS[3]:=NULL}" |
27 | |
28 | # which input devices are we using ? |
29 | ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'") |
30 | export ALX_MOUSE |
31 | } |
32 | |
33 | config_x11() |
34 | { |
35 | # get our settings from the db |
36 | get_x11_settings |
37 | |
38 | local xserver |
39 | local xfconfig |
40 | local HAS_VNC |
41 | local HAS_REALVNC |
42 | local HAS_TIGERVNC |
43 | |
44 | # xfree or xorg ? |
45 | xserver="$(readlink /usr/X11R6/bin/X)" |
46 | |
47 | case ${xserver} in |
48 | Xorg) xfconfig=/etc/X11/xorg.conf ;; |
49 | XFree86) xfconfig=/etc/X11/XF86Config ;; |
50 | *) echo " Unkown xserver. aborting."; exit 1 ;; |
51 | esac |
52 | |
53 | # got we vnc support ? |
54 | if [ -f /usr/X11R6/lib/modules/vnc.so ] |
55 | then |
56 | HAS_VNC="yes" |
57 | else |
58 | HAS_VNC="no" |
59 | fi |
60 | |
61 | if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ] |
62 | then |
63 | HAS_REALVNC="yes" |
64 | else |
65 | HAS_REALVNC="no" |
66 | fi |
67 | |
68 | if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ] |
69 | then |
70 | HAS_TIGERVNC="yes" |
71 | else |
72 | HAS_TIGERVNC="no" |
73 | fi |
74 | |
75 | # show which server we use |
76 | echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server " |
77 | |
78 | # show if we have vnc |
79 | if [[ ${HAS_VNC} = yes ]] |
80 | then |
81 | echo "with vnc enabled ..." |
82 | elif [[ ${HAS_REALVNC} = yes ]] |
83 | then |
84 | echo "with realvnc enabled ..." |
85 | elif [[ ${HAS_TIGERVNC} = yes ]] |
86 | then |
87 | echo "with tigervnc enabled ..." |
88 | else |
89 | echo "..." |
90 | fi |
91 | |
92 | # create a new clear xfconfig file |
93 | echo '# Generated with alxconfig-ng.' > ${xfconfig} |
94 | echo '' >> ${xfconfig} |
95 | |
96 | # write modules |
97 | echo '' >> ${xfconfig} |
98 | echo 'Section "Module"' >> ${xfconfig} |
99 | echo ' Load "dbe"' >> ${xfconfig} |
100 | echo ' SubSection "extmod"' >> ${xfconfig} |
101 | echo ' Option "omit xfree86-dga"' >> ${xfconfig} |
102 | echo ' EndSubSection' >> ${xfconfig} |
103 | echo ' Load "freetype"' >> ${xfconfig} |
104 | echo '# Load "glx"' >> ${xfconfig} |
105 | echo ' Load "dri"' >> ${xfconfig} |
106 | |
107 | [[ ${HAS_VNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} |
108 | [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} |
109 | [[ ${HAS_TIGERVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} |
110 | |
111 | echo 'EndSection' >> ${xfconfig} |
112 | |
113 | # fonts |
114 | echo '' >> ${xfconfig} |
115 | echo 'Section "Files"' >> ${xfconfig} |
116 | |
117 | case ${xserver} in |
118 | Xorg) |
119 | # only add existing font pathes |
120 | [[ -f /usr/share/fonts/local/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig} |
121 | [[ -f /usr/share/fonts/misc/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig} |
122 | [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig} |
123 | [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig} |
124 | [[ -f /usr/share/fonts/TrueType/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig} |
125 | [[ -f /usr/share/fonts/freefont/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig} |
126 | [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig} |
127 | [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig} |
128 | ;; |
129 | XFree86) |
130 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig} |
131 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig} |
132 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig} |
133 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig} |
134 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig} |
135 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig} |
136 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig} |
137 | echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig} |
138 | ;; |
139 | esac |
140 | |
141 | echo 'EndSection' >> ${xfconfig} |
142 | |
143 | # server flags |
144 | echo '' >> ${xfconfig} |
145 | echo 'Section "ServerFlags"' >> ${xfconfig} |
146 | echo '# Option "DontVTSwitch"' >> ${xfconfig} |
147 | echo '# Option "DontZap"' >> ${xfconfig} |
148 | echo '# Option "Dont Zoom"' >> ${xfconfig} |
149 | echo 'EndSection' >> ${xfconfig} |
150 | |
151 | # keyboard |
152 | echo '' >> ${xfconfig} |
153 | echo 'Section "InputDevice"' >> ${xfconfig} |
154 | echo ' Identifier "Keyboard1"' >> ${xfconfig} |
155 | |
156 | case ${xserver} in |
157 | Xorg) echo ' Driver "kbd"' >> ${xfconfig} ;; |
158 | XFree86) echo ' Driver "Keyboard"' >> ${xfconfig} ;; |
159 | esac |
160 | |
161 | echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig} |
162 | echo '# Option "Xleds" "1 2 3"' >> ${xfconfig} |
163 | |
164 | case ${xserver} in |
165 | Xorg) echo ' Option "XkbRules" "xorg"' >> ${xfconfig} ;; |
166 | XFree86) echo ' Option "XkbRules" "xfree86"' >> ${xfconfig} ;; |
167 | esac |
168 | |
169 | echo ' Option "XkbModel" "pc105"' >> ${xfconfig} |
170 | echo ' Option "XkbLayout" "de"' >> ${xfconfig} |
171 | echo 'EndSection' >> ${xfconfig} |
172 | |
173 | # mouse |
174 | echo '' >> ${xfconfig} |
175 | echo 'Section "InputDevice"' >> ${xfconfig} |
176 | echo ' Identifier "Mouse1"' >> ${xfconfig} |
177 | echo ' Driver "mouse"' >> ${xfconfig} |
178 | echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig} |
179 | |
180 | local device |
181 | case ${ALX_MOUSE} in |
182 | IMPS/2|PS/2) device=/dev/psaux;; |
183 | Auto) device=/dev/mouse;; |
184 | *) device=/dev/mouse;; |
185 | esac |
186 | echo " Option \"Device\" \"${device}\"" >> ${xfconfig} |
187 | echo ' Option "Resolution" "1200"' >> ${xfconfig} |
188 | |
189 | [[ ${ALX_MOUSE} = IMPS/2 ]] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig} |
190 | |
191 | echo 'EndSection' >> ${xfconfig} |
192 | |
193 | # vnc keyboard && mouse |
194 | if [[ ${HAS_VNC} = yes ]] |
195 | then |
196 | echo '' >> ${xfconfig} |
197 | echo 'Section "InputDevice"' >> ${xfconfig} |
198 | echo ' Identifier "vncKeyboard"' >> ${xfconfig} |
199 | echo ' Driver "rfbkeyb"' >> ${xfconfig} |
200 | echo 'EndSection' >> ${xfconfig} |
201 | |
202 | echo '' >> ${xfconfig} |
203 | echo 'Section "InputDevice"' >> ${xfconfig} |
204 | echo ' Identifier "vncMouse"' >> ${xfconfig} |
205 | echo ' Driver "rfbmouse"' >> ${xfconfig} |
206 | echo 'EndSection' >> ${xfconfig} |
207 | fi |
208 | |
209 | # monitor |
210 | echo '' >> ${xfconfig} |
211 | echo 'Section "Monitor"' >> ${xfconfig} |
212 | echo ' Identifier "Monitor0"' >> ${xfconfig} |
213 | echo ' Option "DPMS"' >> ${xfconfig} |
214 | |
215 | # add hsync, vrefresh |
216 | if [[ -x /sbin/ddcxinfo-knoppix ]] |
217 | then |
218 | local hsync="$(ddcxinfo-knoppix -hsync)" |
219 | local vsync="$(ddcxinfo-knoppix -vsync)" |
220 | # fallback |
221 | [[ ${hsync} = 0-0 ]] && hsync="28-96" |
222 | [[ ${vsync} = 0-0 ]] && vsync="50-60" |
223 | |
224 | echo '' >> ${xfconfig} |
225 | echo " HorizSync ${hsync}" >> ${xfconfig} |
226 | echo " VertRefresh ${vsync}" >> ${xfconfig} |
227 | fi |
228 | |
229 | # add cvt modelines |
230 | echo '' >> ${xfconfig} |
231 | local cvt="/usr/X11R6/bin/cvt" |
232 | local modeline |
233 | modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":') |
234 | echo "${modeline}" >> ${xfconfig} |
235 | # add ddcxinfo-knoppix modelines (fallback) |
236 | if [[ -x /sbin/ddcxinfo-knoppix ]] |
237 | then |
238 | echo '' >> ${xfconfig} |
239 | ddcxinfo-knoppix -modelines >> ${xfconfig} |
240 | fi |
241 | echo 'EndSection' >> ${xfconfig} |
242 | |
243 | # vga |
244 | echo '' >> ${xfconfig} |
245 | echo 'Section "Device"' >> ${xfconfig} |
246 | echo ' Identifier "vga0"' >> ${xfconfig} |
247 | # check for openchrome and use it if available |
248 | if [[ ${ALX_MODULE} = via ]] && [ -f /usr/X11R6/lib/xorg/modules/drivers/openchrome_drv.so ] |
249 | then |
250 | ALX_MODULE="openchrome" |
251 | fi |
252 | echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig} |
253 | |
254 | # vnc server options |
255 | if [[ ${HAS_VNC} = yes ]] |
256 | then |
257 | echo '' >> ${xfconfig} |
258 | echo ' # rfb options' >> ${xfconfig} |
259 | echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig} |
260 | echo ' Option "rfbport" "5900"' >> ${xfconfig} |
261 | echo ' #Option "nevershared"' >> ${xfconfig} |
262 | echo ' Option "alwaysshared"' >> ${xfconfig} |
263 | echo ' Option "dontdisconnect"' >> ${xfconfig} |
264 | echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig} |
265 | echo ' Option "httpport" "5800"' >> ${xfconfig} |
266 | echo ' # Option "useraccept"' >> ${xfconfig} |
267 | echo ' Option "usevnc"' >> ${xfconfig} |
268 | echo ' # Option "localhost"' >> ${xfconfig} |
269 | echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig} |
270 | echo ' # Option "viewonly"' >> ${xfconfig} |
271 | echo ' # Option "loginauth"' >> ${xfconfig} |
272 | echo '' >> ${xfconfig} |
273 | fi |
274 | |
275 | echo 'EndSection' >> ${xfconfig} |
276 | |
277 | # screens |
278 | echo '' >> ${xfconfig} |
279 | echo 'Section "Screen"' >> ${xfconfig} |
280 | echo ' Identifier "Screen 1"' >> ${xfconfig} |
281 | echo ' Device "vga0"' >> ${xfconfig} |
282 | echo ' Monitor "Monitor0"' >> ${xfconfig} |
283 | echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig} |
284 | echo ' Subsection "Display"' >> ${xfconfig} |
285 | echo " Depth ${ALX_DEPTH}" >> ${xfconfig} |
286 | echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig} |
287 | echo ' ViewPort 0 0' >> ${xfconfig} |
288 | echo ' EndSubsection' >> ${xfconfig} |
289 | |
290 | if [[ ${HAS_REALVNC} = yes ]] || [[ ${HAS_TIGERVNC} = yes ]] |
291 | then |
292 | echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig} |
293 | echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig} |
294 | echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig} |
295 | fi |
296 | echo 'EndSection' >> ${xfconfig} |
297 | |
298 | # server layout |
299 | echo '' >> ${xfconfig} |
300 | echo 'Section "ServerLayout"' >> ${xfconfig} |
301 | echo ' Identifier "Simple Layout"' >> ${xfconfig} |
302 | echo ' Screen "Screen 1"' >> ${xfconfig} |
303 | echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig} |
304 | echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig} |
305 | |
306 | # load vnc keyboard && mouse |
307 | if [[ ${HAS_VNC} = yes ]] |
308 | then |
309 | echo ' InputDevice "vncMouse" "ExtraPointer"' >> ${xfconfig} |
310 | echo ' InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig} |
311 | fi |
312 | |
313 | echo 'EndSection' >> ${xfconfig} |
314 | |
315 | # dri |
316 | echo '' >> ${xfconfig} |
317 | echo 'Section "DRI"' >> ${xfconfig} |
318 | echo ' Mode 0666' >> ${xfconfig} |
319 | echo 'EndSection' >> ${xfconfig} |
320 | } |
321 |