Magellan Linux

Annotation of /alx-src/trunk/tinyalxconfig-ng/functions/config_x11.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 386 - (hide annotations) (download) (as text)
Wed Jun 4 16:47:56 2008 UTC (15 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 11284 byte(s)
-initial import

1 niro 386 # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/config_x11.sh,v 1.1 2008-06-04 16:47:56 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    
8     # autodetect or not ?
9     if [ $(mysqldo "select monitorid from cfg_graphic where serial='${ALX_SERIAL}'") -gt 0 ]
10     then
11     # settings from db
12    
13     all=$(mysqldo "select cfg_graphic.module,
14     cfg_graphic.resolution,
15     cfg_graphic.depth,
16     list_monitors.vendor,
17     list_monitors.model,
18     list_monitors.hsync,
19     list_monitors.vrefresh
20     from list_monitors
21     inner join cfg_graphic
22     on cfg_graphic.monitorid=list_monitors.id
23     and cfg_graphic.serial='${ALX_SERIAL}';")
24    
25     # split'em up and put 'em in an array
26     declare -i i=0
27     for x in ${all}
28     do
29     DB_X11SETTINGS[${i}]="${x}"
30     ((i++))
31     done
32    
33     # and now put them in usable var names and export them systemwide
34     export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"
35     export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"
36     export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"
37     export ALX_VENDOR="${DB_X11SETTINGS[3]:=NULL}"
38     export ALX_MODEL="${DB_X11SETTINGS[4]:=NULL}"
39     export ALX_HSYNC="${DB_X11SETTINGS[5]:=NULL}"
40     export ALX_VREF="${DB_X11SETTINGS[6]:=NULL}"
41     else
42     # autodetect
43     all=$(mysqldo "select module,
44     resolution,
45     depth
46     from cfg_graphic where serial='${ALX_SERIAL}'")
47    
48     # split'em up and put 'em in an array
49     declare -i i=0
50     for x in ${all}
51     do
52     DB_X11SETTINGS[${i}]="${x}"
53     ((i++))
54     done
55    
56     # and now put them in usable var names and export them systemwide
57     export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"
58     export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"
59     export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"
60     export ALX_VENDOR="Autodetected"
61     export ALX_MODEL="Monitor"
62     export ALX_HSYNC="auto"
63     export ALX_VREF="auto"
64     fi
65    
66     # which input devices are we using ?
67     ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")
68     export ALX_MOUSE
69    
70     ALX_MOUSE_ACCELERATION=$(mysqldo "select mouse_acceleration from cfg_input where serial='${ALX_SERIAL}'")
71     ALX_MOUSE_THRESHOLD=$(mysqldo "select mouse_threshold from cfg_input where serial='${ALX_SERIAL}'")
72     export ALX_MOUSE_ACCELERATION
73     export ALX_MOUSE_THRESHOLD
74     }
75    
76     config_x11()
77     {
78     # get our settings from the db
79     get_x11_settings
80    
81     local xserver
82     local xfconfig
83     local HAS_VNC
84     local HAS_REALVNC
85    
86     # xfree or xorg ?
87     xserver="$(readlink /usr/X11R6/bin/X)"
88    
89     case ${xserver} in
90     Xorg)
91     xfconfig=/etc/X11/xorg.conf
92     ;;
93     XFree86)
94     xfconfig=/etc/X11/XF86Config
95     ;;
96     *)
97     echo " Unkown xserver. aborting."
98     exit 1
99     ;;
100     esac
101    
102     # got we vnc support ?
103     if [ -f /usr/X11R6/lib/modules/vnc.so ]
104     then
105     HAS_VNC="yes"
106     else
107     HAS_VNC="no"
108     fi
109    
110     if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]
111     then
112     HAS_REALVNC="yes"
113     else
114     HAS_REALVNC="no"
115     fi
116    
117     # show which server we use
118     echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "
119    
120     # show if we have vnc
121     if [[ ${HAS_VNC} = yes ]]
122     then
123     echo "with vnc enabled ..."
124     elif [[ ${HAS_REALVNC} = yes ]]
125     then
126     echo "with realvnc enabled ..."
127     else
128     echo "..."
129     fi
130    
131     # create a new clear xfconfig file
132     echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig}
133     echo '' >> ${xfconfig}
134    
135     # write modules
136     echo '' >> ${xfconfig}
137     echo 'Section "Module"' >> ${xfconfig}
138     echo ' Load "dbe"' >> ${xfconfig}
139     echo ' SubSection "extmod"' >> ${xfconfig}
140     echo ' Option "omit xfree86-dga"' >> ${xfconfig}
141     echo ' EndSubSection' >> ${xfconfig}
142     echo ' Load "type1"' >> ${xfconfig}
143     echo ' Load "speedo"' >> ${xfconfig}
144     echo ' Load "freetype"' >> ${xfconfig}
145     echo '# Load "xtt"' >> ${xfconfig}
146     echo '# Load "glx"' >> ${xfconfig}
147     echo ' Load "dri"' >> ${xfconfig}
148    
149     [[ ${HAS_VNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
150     [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
151    
152     echo 'EndSection' >> ${xfconfig}
153    
154     # fonts
155     echo '' >> ${xfconfig}
156     echo 'Section "Files"' >> ${xfconfig}
157     echo ' RgbPath "/usr/X11R6/lib/X11/rgb"' >> ${xfconfig}
158    
159     case ${xserver} in
160     Xorg)
161     echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig}
162     echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig}
163     echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}
164     echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}
165     echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}
166     echo ' #FontPath "/usr/share/fonts/Speedo/"' >> ${xfconfig}
167     echo ' #FontPath "/usr/share/fonts/Type1/"' >> ${xfconfig}
168     echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig}
169     echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig}
170     echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig}
171     echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig}
172     ;;
173     XFree86)
174     echo ' FontPath "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig}
175     echo ' FontPath "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}
176     echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig}
177     echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig}
178     echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}
179     echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"' >> ${xfconfig}
180     echo ' #FontPath "/usr/X11R6/lib/X11/fonts/Type1/"' >> ${xfconfig}
181     echo ' FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}
182     echo ' FontPath "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}
183     echo ' FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}
184     echo ' FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig}
185     ;;
186     esac
187    
188     echo '# ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig}
189     echo 'EndSection' >> ${xfconfig}
190    
191     # server flags
192     echo '' >> ${xfconfig}
193     echo 'Section "ServerFlags"' >> ${xfconfig}
194     echo '# Option "DontVTSwitch"' >> ${xfconfig}
195     echo '# Option "DontZap"' >> ${xfconfig}
196     echo '# Option "Dont Zoom"' >> ${xfconfig}
197     echo 'EndSection' >> ${xfconfig}
198    
199     # keyboard
200     echo '' >> ${xfconfig}
201     echo 'Section "InputDevice"' >> ${xfconfig}
202     echo ' Identifier "Keyboard1"' >> ${xfconfig}
203    
204     case ${xserver} in
205     Xorg)
206     echo ' Driver "kbd"' >> ${xfconfig}
207     ;;
208     XFree86)
209     echo ' Driver "Keyboard"' >> ${xfconfig}
210     ;;
211     esac
212    
213     echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig}
214     echo '# Option "Xleds" "1 2 3"' >> ${xfconfig}
215    
216     case ${xserver} in
217     Xorg)
218     echo ' Option "XkbRules" "xorg"' >> ${xfconfig}
219     ;;
220     XFree86)
221     echo ' Option "XkbRules" "xfree86"' >> ${xfconfig}
222     ;;
223     esac
224    
225     echo ' Option "XkbModel" "pc105"' >> ${xfconfig}
226     echo ' Option "XkbLayout" "de"' >> ${xfconfig}
227     echo 'EndSection' >> ${xfconfig}
228    
229     # mouse
230     echo '' >> ${xfconfig}
231     echo 'Section "InputDevice"' >> ${xfconfig}
232     echo ' Identifier "Mouse1"' >> ${xfconfig}
233     echo ' Driver "mouse"' >> ${xfconfig}
234     echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig}
235    
236     local device
237     case ${ALX_MOUSE} in
238     IMPS/2|PS/2) device=/dev/psaux;;
239     Auto) device=/dev/mouse;;
240     *) device=/dev/mouse;;
241     esac
242     echo " Option \"Device\" \"${device}\"" >> ${xfconfig}
243     echo ' Option "Resolution" "1200"' >> ${xfconfig}
244    
245     [[ ${ALX_MOUSE} = IMPS/2 ]] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig}
246    
247     echo 'EndSection' >> ${xfconfig}
248    
249     # vnc keyboard && mouse
250     if [[ ${HAS_VNC} = yes ]]
251     then
252     echo '' >> ${xfconfig}
253     echo 'Section "InputDevice"' >> ${xfconfig}
254     echo ' Identifier "vncKeyboard"' >> ${xfconfig}
255     echo ' Driver "rfbkeyb"' >> ${xfconfig}
256     echo 'EndSection' >> ${xfconfig}
257    
258     echo '' >> ${xfconfig}
259     echo 'Section "InputDevice"' >> ${xfconfig}
260     echo ' Identifier "vncMouse"' >> ${xfconfig}
261     echo ' Driver "rfbmouse"' >> ${xfconfig}
262     echo 'EndSection' >> ${xfconfig}
263     fi
264    
265     # monitor
266     if [ -x "/sbin/ddcxinfo-knoppix" ] &&
267     [[ ${ALX_HSYNC} = auto ]] ||
268     [[ ${ALX_VREF} = auto ]]
269     then
270     ddcxinfo-knoppix -monitor >> ${xfconfig}
271     else
272     echo '' >> ${xfconfig}
273     echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig}
274     echo 'Section "Monitor"' >> ${xfconfig}
275     echo ' Identifier "Monitor0"' >> ${xfconfig}
276     echo " HorizSync ${ALX_HSYNC}" >> ${xfconfig}
277     echo " VertRefresh ${ALX_VREF}" >> ${xfconfig}
278     echo ' Option "DPMS"' >> ${xfconfig}
279     echo 'EndSection' >> ${xfconfig}
280     fi
281    
282     # vga
283     echo '' >> ${xfconfig}
284     echo 'Section "Device"' >> ${xfconfig}
285     echo ' Identifier "vga0"' >> ${xfconfig}
286     echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig}
287    
288     # vnc server options
289     if [[ ${HAS_VNC} = yes ]]
290     then
291     echo '' >> ${xfconfig}
292     echo ' # rfb options' >> ${xfconfig}
293     echo ' Option "rfbauth" "/root/.vnc/passwd"' >> ${xfconfig}
294     echo ' Option "rfbport" "5900"' >> ${xfconfig}
295     echo ' #Option "nevershared"' >> ${xfconfig}
296     echo ' Option "alwaysshared"' >> ${xfconfig}
297     echo ' Option "dontdisconnect"' >> ${xfconfig}
298     echo ' Option "httpdir" "/usr/share/vnc/classes"' >> ${xfconfig}
299     echo ' Option "httpport" "5800"' >> ${xfconfig}
300     echo ' # Option "useraccept"' >> ${xfconfig}
301     echo ' Option "usevnc"' >> ${xfconfig}
302     echo ' # Option "localhost"' >> ${xfconfig}
303     echo ' # Option "interface" "192.168.0.1"' >> ${xfconfig}
304     echo ' # Option "viewonly"' >> ${xfconfig}
305     echo ' # Option "loginauth"' >> ${xfconfig}
306     echo '' >> ${xfconfig}
307     fi
308    
309     echo 'EndSection' >> ${xfconfig}
310    
311     # screens
312     echo '' >> ${xfconfig}
313     echo 'Section "Screen"' >> ${xfconfig}
314     echo ' Identifier "Screen 1"' >> ${xfconfig}
315     echo ' Device "vga0"' >> ${xfconfig}
316     echo ' Monitor "Monitor0"' >> ${xfconfig}
317     echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}
318     echo ' Subsection "Display"' >> ${xfconfig}
319     echo " Depth ${ALX_DEPTH}" >> ${xfconfig}
320     echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig}
321     echo ' ViewPort 0 0' >> ${xfconfig}
322     echo ' EndSubsection' >> ${xfconfig}
323    
324     if [[ ${HAS_REALVNC} = yes ]]
325     then
326     echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig}
327     echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}
328     echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}
329     fi
330     echo 'EndSection' >> ${xfconfig}
331    
332     # server layout
333     echo '' >> ${xfconfig}
334     echo 'Section "ServerLayout"' >> ${xfconfig}
335     echo ' Identifier "Simple Layout"' >> ${xfconfig}
336     echo ' Screen "Screen 1"' >> ${xfconfig}
337     echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
338     echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
339    
340     # load vnc keyboard && mouse
341     if [[ ${HAS_VNC} = yes ]]
342     then
343     echo ' InputDevice "vncMouse" "ExtraPointer"' >> ${xfconfig}
344     echo ' InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}
345     fi
346    
347     echo 'EndSection' >> ${xfconfig}
348    
349     # dri (here disabled, use default of xserver)
350     echo '' >> ${xfconfig}
351     echo '# Section "DRI"' >> ${xfconfig}
352     echo '# Mode 0666' >> ${xfconfig}
353     echo '# EndSection' >> ${xfconfig}
354    
355     echo "ALX_MOUSE_ACCELERATION=\"${ALX_MOUSE_ACCELERATION}\"" > ${SETTINGSPATH}/mouse
356     echo "ALX_MOUSE_THRESHOLD=\"${ALX_MOUSE_THRESHOLD}\"" >> ${SETTINGSPATH}/mouse
357     }
358