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