Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 477 - (show annotations) (download) (as text)
Sat Jun 7 09:43:17 2008 UTC (15 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 8108 byte(s)
-fixed whitespaces

1 # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/config_x11.sh,v 1.6 2008-06-07 09:43:17 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_REALVNC=no
84
85 # xfree or xorg ?
86 xserver="Xorg"
87 # todo: maybe kdrive support?
88 case ${xserver} in
89 Xorg) xfconfig=/etc/X11/xorg.conf ;;
90 esac
91
92 [ -f /usr/lib/modules/extensions/vnc.so ] && HAS_REALVNC="yes"
93
94 # show which server we use
95 echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "
96
97 # show if we have vnc
98 if [[ ${HAS_REALVNC} = yes ]]
99 then
100 echo "with realvnc enabled ..."
101 else
102 echo "..."
103 fi
104
105 # create a new clear xfconfig file
106 echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig}
107 echo '' >> ${xfconfig}
108
109 # write modules
110 echo '' >> ${xfconfig}
111 echo 'Section "Module"' >> ${xfconfig}
112 echo ' Load "dbe"' >> ${xfconfig}
113 echo ' SubSection "extmod"' >> ${xfconfig}
114 echo ' Option "omit xfree86-dga"' >> ${xfconfig}
115 echo ' EndSubSection' >> ${xfconfig}
116 echo ' Load "type1"' >> ${xfconfig}
117 echo ' Load "speedo"' >> ${xfconfig}
118 echo ' Load "freetype"' >> ${xfconfig}
119 echo '# Load "xtt"' >> ${xfconfig}
120 echo '# Load "glx"' >> ${xfconfig}
121 echo ' Load "dri"' >> ${xfconfig}
122
123 [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig}
124
125 echo 'EndSection' >> ${xfconfig}
126
127 # fonts
128 echo '' >> ${xfconfig}
129 echo 'Section "Files"' >> ${xfconfig}
130 echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig}
131 echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig}
132 echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}
133 echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig}
134 # not provided by tinyALX
135 #echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}
136 #echo ' #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}
137 #echo ' #FontPath "/usr/share/fonts/Speedo/"' >> ${xfconfig}
138 #echo ' #FontPath "/usr/share/fonts/Type1/"' >> ${xfconfig}
139 #echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig}
140 #echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig}
141 #echo ' FontPath "/usr/share/fonts/100dpi/"' >> ${xfconfig}
142 echo 'EndSection' >> ${xfconfig}
143
144 # server flags
145 echo '' >> ${xfconfig}
146 echo 'Section "ServerFlags"' >> ${xfconfig}
147 echo '# Option "DontVTSwitch"' >> ${xfconfig}
148 echo '# Option "DontZap"' >> ${xfconfig}
149 echo '# Option "Dont Zoom"' >> ${xfconfig}
150 echo 'EndSection' >> ${xfconfig}
151
152 # keyboard
153 echo '' >> ${xfconfig}
154 echo 'Section "InputDevice"' >> ${xfconfig}
155 echo ' Identifier "Keyboard1"' >> ${xfconfig}
156 echo ' Driver "kbd"' >> ${xfconfig}
157 echo ' Option "AutoRepeat" "500 30"' >> ${xfconfig}
158 echo '# Option "Xleds" "1 2 3"' >> ${xfconfig}
159 echo ' Option "XkbRules" "xorg"' >> ${xfconfig}
160 echo ' Option "XkbModel" "pc105"' >> ${xfconfig}
161 echo ' Option "XkbLayout" "de"' >> ${xfconfig}
162 echo 'EndSection' >> ${xfconfig}
163
164 # mouse
165 echo '' >> ${xfconfig}
166 echo 'Section "InputDevice"' >> ${xfconfig}
167 echo ' Identifier "Mouse1"' >> ${xfconfig}
168 echo ' Driver "mouse"' >> ${xfconfig}
169 echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig}
170
171 local device
172 case ${ALX_MOUSE} in
173 IMPS/2|PS/2) device=/dev/input/mice;;
174 Auto) device=/dev/mouse;;
175 *) device=/dev/mouse;;
176 esac
177 echo " Option \"Device\" \"${device}\"" >> ${xfconfig}
178 echo ' Option "Resolution" "1200"' >> ${xfconfig}
179
180 [[ ${ALX_MOUSE} = IMPS/2 ]] && echo ' Option "ZAxisMapping" "4 5"' >> ${xfconfig}
181
182 echo 'EndSection' >> ${xfconfig}
183
184 # monitor
185 if [ -x /sbin/ddcxinfo-knoppix ] &&
186 [[ ${ALX_HSYNC} = auto ]] ||
187 [[ ${ALX_VREF} = auto ]]
188 then
189 ddcxinfo-knoppix -monitor >> ${xfconfig}
190 else
191 echo '' >> ${xfconfig}
192 echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig}
193 echo 'Section "Monitor"' >> ${xfconfig}
194 echo ' Identifier "Monitor0"' >> ${xfconfig}
195 echo " HorizSync ${ALX_HSYNC}" >> ${xfconfig}
196 echo " VertRefresh ${ALX_VREF}" >> ${xfconfig}
197 echo ' Option "DPMS"' >> ${xfconfig}
198 echo 'EndSection' >> ${xfconfig}
199 fi
200
201 # vga
202 echo '' >> ${xfconfig}
203 echo 'Section "Device"' >> ${xfconfig}
204 echo ' Identifier "vga0"' >> ${xfconfig}
205 echo " Driver \"${ALX_MODULE}\"" >> ${xfconfig}
206 echo 'EndSection' >> ${xfconfig}
207
208 # screens
209 echo '' >> ${xfconfig}
210 echo 'Section "Screen"' >> ${xfconfig}
211 echo ' Identifier "Screen 1"' >> ${xfconfig}
212 echo ' Device "vga0"' >> ${xfconfig}
213 echo ' Monitor "Monitor0"' >> ${xfconfig}
214 echo " DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}
215 echo ' Subsection "Display"' >> ${xfconfig}
216 echo " Depth ${ALX_DEPTH}" >> ${xfconfig}
217 echo " Modes \"${ALX_RESOLUTION}\"" >> ${xfconfig}
218 echo ' ViewPort 0 0' >> ${xfconfig}
219 echo ' EndSubsection' >> ${xfconfig}
220
221 if [[ ${HAS_REALVNC} = yes ]]
222 then
223 echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig}
224 echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}
225 echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}
226 fi
227 echo 'EndSection' >> ${xfconfig}
228
229 # server layout
230 echo '' >> ${xfconfig}
231 echo 'Section "ServerLayout"' >> ${xfconfig}
232 echo ' Identifier "Simple Layout"' >> ${xfconfig}
233 echo ' Screen "Screen 1"' >> ${xfconfig}
234 echo ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
235 echo ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
236 echo 'EndSection' >> ${xfconfig}
237
238 # dri (here disabled, use default of xserver)
239 echo '' >> ${xfconfig}
240 echo '# Section "DRI"' >> ${xfconfig}
241 echo '# Mode 0666' >> ${xfconfig}
242 echo '# EndSection' >> ${xfconfig}
243
244 install -d ${SETTINGSPATH}
245 echo "ALX_MOUSE_ACCELERATION=\"${ALX_MOUSE_ACCELERATION}\"" > ${SETTINGSPATH}/mouse
246 echo "ALX_MOUSE_THRESHOLD=\"${ALX_MOUSE_THRESHOLD}\"" >> ${SETTINGSPATH}/mouse
247 }