Magellan Linux

Contents of /alx-src/branches/alxconf-060/functions/config_x11.sh

Parent Directory Parent Directory | Revision Log Revision Log


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