Magellan Linux

Contents of /alx-src/branches/alxconf_20060908/functions/config_x11.sh

Parent Directory Parent Directory | Revision Log Revision Log


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