Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1582 - (show annotations) (download) (as text)
Tue Nov 23 12:24:14 2010 UTC (13 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 8817 byte(s)
-added config_version and import current version info to database
-use new key refresh_rate and deprecate monitorid for x11 graphics
-updated xorg.conf and use cvt to calculate modelines with given refresh_rate
-enabled dri
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
43 # xfree or xorg ?
44 xserver="$(readlink /usr/X11R6/bin/X)"
45
46 case ${xserver} in
47 Xorg) xfconfig=/etc/X11/xorg.conf ;;
48 XFree86) xfconfig=/etc/X11/XF86Config ;;
49 *) echo " Unkown xserver. aborting."; exit 1 ;;
50 esac
51
52 # got we vnc support ?
53 if [ -f /usr/X11R6/lib/modules/vnc.so ]
54 then
55 HAS_VNC="yes"
56 else
57 HAS_VNC="no"
58 fi
59
60 if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]
61 then
62 HAS_REALVNC="yes"
63 else
64 HAS_REALVNC="no"
65 fi
66
67 # show which server we use
68 echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "
69
70 # show if we have vnc
71 if [[ ${HAS_VNC} = yes ]]
72 then
73 echo "with vnc enabled ..."
74 elif [[ ${HAS_REALVNC} = yes ]]
75 then
76 echo "with realvnc enabled ..."
77 else
78 echo "..."
79 fi
80
81 # create a new clear xfconfig file
82 echo '# Generated with alxconfig-ng.' > ${xfconfig}
83 echo '' >> ${xfconfig}
84
85 # write modules
86 echo '' >> ${xfconfig}
87 echo 'Section "Module"' >> ${xfconfig}
88 echo ' Load "dbe"' >> ${xfconfig}
89 echo ' SubSection "extmod"' >> ${xfconfig}
90 echo ' Option "omit xfree86-dga"' >> ${xfconfig}
91 echo ' EndSubSection' >> ${xfconfig}
92 echo ' Load "freetype"' >> ${xfconfig}
93 echo '# Load "glx"' >> ${xfconfig}
94 echo ' Load "dri"' >> ${xfconfig}
95
96 [[ ${HAS_VNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
97 [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
98
99 echo 'EndSection' >> ${xfconfig}
100
101 # fonts
102 echo '' >> ${xfconfig}
103 echo 'Section "Files"' >> ${xfconfig}
104
105 case ${xserver} in
106 Xorg)
107 echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig}
108 echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig}
109 echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}
110 echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}
111 echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig}
112 echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig}
113 echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig}
114 echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig}
115 ;;
116 XFree86)
117 echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig}
118 echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}
119 echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig}
120 echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig}
121 echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}
122 echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}
123 echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}
124 echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig}
125 ;;
126 esac
127
128 echo 'EndSection' >> ${xfconfig}
129
130 # server flags
131 echo '' >> ${xfconfig}
132 echo 'Section "ServerFlags"' >> ${xfconfig}
133 echo '# Option "DontVTSwitch"' >> ${xfconfig}
134 echo '# Option "DontZap"' >> ${xfconfig}
135 echo '# Option "Dont Zoom"' >> ${xfconfig}
136 echo 'EndSection' >> ${xfconfig}
137
138 # keyboard
139 echo '' >> ${xfconfig}
140 echo 'Section "InputDevice"' >> ${xfconfig}
141 echo ' Identifier "Keyboard1"' >> ${xfconfig}
142
143 case ${xserver} in
144 Xorg) echo ' Driver "kbd"' >> ${xfconfig} ;;
145 XFree86) echo ' Driver "Keyboard"' >> ${xfconfig} ;;
146 esac
147
148 echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig}
149 echo '# Option "Xleds" "1 2 3"' >> ${xfconfig}
150
151 case ${xserver} in
152 Xorg) echo ' Option "XkbRules" "xorg"' >> ${xfconfig} ;;
153 XFree86) echo ' Option "XkbRules" "xfree86"' >> ${xfconfig} ;;
154 esac
155
156 echo ' Option "XkbModel" "pc105"' >> ${xfconfig}
157 echo ' Option "XkbLayout" "de"' >> ${xfconfig}
158 echo 'EndSection' >> ${xfconfig}
159
160 # mouse
161 echo '' >> ${xfconfig}
162 echo 'Section "InputDevice"' >> ${xfconfig}
163 echo ' Identifier "Mouse1"' >> ${xfconfig}
164 echo ' Driver "mouse"' >> ${xfconfig}
165 echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig}
166
167 local device
168 case ${ALX_MOUSE} in
169 IMPS/2|PS/2) device=/dev/psaux;;
170 Auto) device=/dev/mouse;;
171 *) device=/dev/mouse;;
172 esac
173 echo " Option \"Device\" \"${device}\"" >> ${xfconfig}
174 echo ' Option "Resolution" "1200"' >> ${xfconfig}
175
176 [[ ${ALX_MOUSE} = IMPS/2 ]] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig}
177
178 echo 'EndSection' >> ${xfconfig}
179
180 # vnc keyboard && mouse
181 if [[ ${HAS_VNC} = yes ]]
182 then
183 echo '' >> ${xfconfig}
184 echo 'Section "InputDevice"' >> ${xfconfig}
185 echo ' Identifier "vncKeyboard"' >> ${xfconfig}
186 echo ' Driver "rfbkeyb"' >> ${xfconfig}
187 echo 'EndSection' >> ${xfconfig}
188
189 echo '' >> ${xfconfig}
190 echo 'Section "InputDevice"' >> ${xfconfig}
191 echo ' Identifier "vncMouse"' >> ${xfconfig}
192 echo ' Driver "rfbmouse"' >> ${xfconfig}
193 echo 'EndSection' >> ${xfconfig}
194 fi
195
196 # monitor
197 echo 'Section "Monitor"' >> ${xfconfig}
198 echo ' Identifier "Monitor0"' >> ${xfconfig}
199 echo ' Option "DPMS"' >> ${xfconfig}
200 echo '' >> ${xfconfig}
201 # add cvt modelines
202 local cvt="/usr/X11R6/bin/cvt"
203 local modeline
204 modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
205 echo "${modeline}" >> ${xfconfig}
206 echo 'EndSection' >> ${xfconfig}
207
208 # vga
209 echo '' >> ${xfconfig}
210 echo 'Section "Device"' >> ${xfconfig}
211 echo ' Identifier "vga0"' >> ${xfconfig}
212 echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig}
213
214 # vnc server options
215 if [[ ${HAS_VNC} = yes ]]
216 then
217 echo '' >> ${xfconfig}
218 echo ' # rfb options' >> ${xfconfig}
219 echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig}
220 echo ' Option "rfbport" "5900"' >> ${xfconfig}
221 echo ' #Option "nevershared"' >> ${xfconfig}
222 echo ' Option "alwaysshared"' >> ${xfconfig}
223 echo ' Option "dontdisconnect"' >> ${xfconfig}
224 echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig}
225 echo ' Option "httpport" "5800"' >> ${xfconfig}
226 echo ' # Option "useraccept"' >> ${xfconfig}
227 echo ' Option "usevnc"' >> ${xfconfig}
228 echo ' # Option "localhost"' >> ${xfconfig}
229 echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig}
230 echo ' # Option "viewonly"' >> ${xfconfig}
231 echo ' # Option "loginauth"' >> ${xfconfig}
232 echo '' >> ${xfconfig}
233 fi
234
235 echo 'EndSection' >> ${xfconfig}
236
237 # screens
238 echo '' >> ${xfconfig}
239 echo 'Section "Screen"' >> ${xfconfig}
240 echo ' Identifier "Screen 1"' >> ${xfconfig}
241 echo ' Device "vga0"' >> ${xfconfig}
242 echo ' Monitor "Monitor0"' >> ${xfconfig}
243 echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}
244 echo ' Subsection "Display"' >> ${xfconfig}
245 echo " Depth ${ALX_DEPTH}" >> ${xfconfig}
246 echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig}
247 echo ' ViewPort 0 0' >> ${xfconfig}
248 echo ' EndSubsection' >> ${xfconfig}
249
250 if [[ ${HAS_REALVNC} = yes ]]
251 then
252 echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig}
253 echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}
254 echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}
255 fi
256 echo 'EndSection' >> ${xfconfig}
257
258 # server layout
259 echo '' >> ${xfconfig}
260 echo 'Section "ServerLayout"' >> ${xfconfig}
261 echo ' Identifier "Simple Layout"' >> ${xfconfig}
262 echo ' Screen "Screen 1"' >> ${xfconfig}
263 echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
264 echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
265
266 # load vnc keyboard && mouse
267 if [[ ${HAS_VNC} = yes ]]
268 then
269 echo ' InputDevice "vncMouse" "ExtraPointer"' >> ${xfconfig}
270 echo ' InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}
271 fi
272
273 echo 'EndSection' >> ${xfconfig}
274
275 # dri
276 echo '' >> ${xfconfig}
277 echo 'Section "DRI"' >> ${xfconfig}
278 echo ' Mode 0666' >> ${xfconfig}
279 echo 'EndSection' >> ${xfconfig}
280 }
281