Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2004 - (show annotations) (download) (as text)
Mon May 9 14:57:16 2011 UTC (12 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 6870 byte(s)
-fixed header
-added clearconfig and addconfig functions and use them
-clean up old cruft, we do not support old configurations anymore
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 # 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 clearconfig()
48 {
49 local xfconfig="/etc/X11/xorg.conf"
50 :> ${xfconfig}
51 }
52
53 addconfig()
54 {
55 local value="$@"
56 local xfconfig="/etc/X11/xorg.conf"
57
58 echo "${value}" >> ${xfconfig}
59 }
60
61 config_x11()
62 {
63 # get our settings from the db
64 get_x11_settings
65
66 # setup displaymanager
67 config_display_manager
68
69 local xserver=Xorg
70 local HAS_TIGERVNC
71
72 # got we vnc support ?
73 if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ]
74 then
75 HAS_TIGERVNC="yes"
76 else
77 HAS_TIGERVNC="no"
78 fi
79
80 # show which server we use
81 echo -en ${COLOREDSTAR}"Configuring Xorg x11-server "
82
83 # show if we have vnc
84 if [[ ${HAS_TIGERVNC} = yes ]]
85 then
86 echo "with tigervnc enabled ..."
87 else
88 echo "..."
89 fi
90
91 # create a new clear xfconfig file
92 clearconfig
93 addconfig '# Generated with alxconfig-ng.'
94 addconfig
95
96 # write modules
97 addconfig
98 addconfig 'Section "Module"'
99 addconfig ' Load "dbe"'
100 addconfig ' SubSection "extmod"'
101 addconfig ' Option "omit xfree86-dga"'
102 addconfig ' EndSubSection'
103 addconfig ' Load "freetype"'
104 addconfig '# Load "glx"'
105 addconfig ' Load "dri"'
106
107 [[ ${HAS_TIGERVNC} = yes ]] && addconfig ' Load "vnc"'
108
109 addconfig 'EndSection'
110
111 # fonts
112 addconfig
113 addconfig 'Section "Files"'
114 # only add existing font pathes
115 [[ -f /usr/share/fonts/local/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/local/"'
116 [[ -f /usr/share/fonts/misc/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/misc/"'
117 [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/75dpi/:unscaled"'
118 [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/100dpi/:unscaled"'
119 [[ -f /usr/share/fonts/TrueType/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/TrueType/"'
120 [[ -f /usr/share/fonts/freefont/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/freefont/"'
121 [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/75dpi/"'
122 [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/100dpi/"'
123 addconfig 'EndSection'
124
125 # server flags
126 addconfig
127 addconfig 'Section "ServerFlags"'
128 addconfig '# Option "DontVTSwitch"'
129 addconfig '# Option "DontZap"'
130 addconfig '# Option "Dont Zoom"'
131 addconfig 'EndSection'
132
133 # keyboard
134 addconfig
135 addconfig 'Section "InputDevice"'
136 addconfig ' Identifier "Keyboard1"'
137 addconfig ' Driver "kbd"'
138 addconfig ' Option "AutoRepeat" "500 30"'
139 addconfig '# Option "Xleds" "1 2 3"'
140 addconfig ' Option "XkbRules" "xorg"'
141 addconfig ' Option "XkbModel" "pc105"'
142 addconfig ' Option "XkbLayout" "de"'
143 addconfig 'EndSection'
144
145 # mouse
146 addconfig
147 addconfig 'Section "InputDevice"'
148 addconfig ' Identifier "Mouse1"'
149 addconfig ' Driver "mouse"'
150 addconfig " Option \"Protocol\" \"${ALX_MOUSE}\""
151 local device
152 case ${ALX_MOUSE} in
153 IMPS/2|PS/2) device=/dev/psaux;;
154 Auto) device=/dev/mouse;;
155 *) device=/dev/mouse;;
156 esac
157 addconfig " Option \"Device\" \"${device}\""
158 [[ -z ${ALX_MOUSE_RESOLUTION} ]] && ALX_MOUSE_RESOLUTION="1200"
159 addconfig " Option \"Resolution\" \"${ALX_MOUSE_RESOLUTION}\""
160 [[ ${ALX_MOUSE} = IMPS/2 ]] && addconfig ' Option "ZAxisMapping" "4 5"'
161 addconfig 'EndSection' >> ${xfconfig}
162
163 # monitor
164 addconfig
165 addconfig 'Section "Monitor"'
166 addconfig ' Identifier "Monitor0"'
167 addconfig ' Option "DPMS"'
168
169 # add hsync, vrefresh
170 if [[ -x /sbin/ddcxinfo-knoppix ]]
171 then
172 local hsync="$(ddcxinfo-knoppix -hsync)"
173 local vsync="$(ddcxinfo-knoppix -vsync)"
174 # fallback
175 [[ ${hsync} = 0-0 ]] && hsync="28-96"
176 [[ ${vsync} = 0-0 ]] && vsync="50-60"
177
178 addconfig
179 addconfig " HorizSync ${hsync}"
180 addconfig " VertRefresh ${vsync}"
181 fi
182
183 # add cvt modelines
184 addconfig
185 local cvt="/usr/X11R6/bin/cvt"
186 local modeline
187 modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
188 addconfig "${modeline}"
189 # add ddcxinfo-knoppix modelines (fallback)
190 if [[ -x /sbin/ddcxinfo-knoppix ]]
191 then
192 addconfig
193 addconfig $(ddcxinfo-knoppix -modelines)
194 fi
195 addconfig 'EndSection'
196
197 # vga
198 addconfig
199 addconfig 'Section "Device"'
200 addconfig ' Identifier "vga0"'
201 # check for openchrome and use it if available
202 if [[ ${ALX_MODULE} = via ]] && [ -f /usr/X11R6/lib/xorg/modules/drivers/openchrome_drv.so ]
203 then
204 ALX_MODULE="openchrome"
205 fi
206 addconfig " Driver \"${ALX_MODULE}\""
207 addconfig 'EndSection'
208
209 # screens
210 addconfig
211 addconfig 'Section "Screen"'
212 addconfig ' Identifier "Screen 1"'
213 addconfig ' Device "vga0"'
214 addconfig ' Monitor "Monitor0"'
215 addconfig " DefaultDepth ${ALX_DEPTH}"
216 addconfig ' Subsection "Display"'
217 addconfig " Depth ${ALX_DEPTH}"
218 addconfig " Modes \"${ALX_RESOLUTION}\""
219 addconfig ' ViewPort 0 0'
220 addconfig ' EndSubsection'
221 if [[ ${HAS_TIGERVNC} = yes ]]
222 then
223 addconfig ' Option "SecurityTypes" "VncAuth"'
224 addconfig ' Option "UserPasswdVerifier" "VncAuth"'
225 addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
226 fi
227 addconfig 'EndSection'
228
229 # server layout
230 addconfig
231 addconfig 'Section "ServerLayout"' >> ${xfconfig}
232 addconfig ' Identifier "Simple Layout"' >> ${xfconfig}
233 addconfig ' Screen "Screen 1"' >> ${xfconfig}
234 addconfig ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
235 addconfig ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
236 addconfig 'EndSection' >> ${xfconfig}
237
238 # dri
239 addconfig
240 addconfig 'Section "DRI"' >> ${xfconfig}
241 addconfig ' Mode 0666' >> ${xfconfig}
242 addconfig 'EndSection' >> ${xfconfig}
243 }