Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2004 - (hide annotations) (download) (as text)
Mon May 9 14:57:16 2011 UTC (13 years 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 niro 2004 # $Id$
2 niro 218 # 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 niro 1582 # autodetect
8     all=$(mysqldo "select module,
9     resolution,
10     depth,
11     refresh_rate
12     from cfg_graphic where serial='${ALX_SERIAL}'")
13 niro 218
14 niro 1582 # 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 niro 218
22 niro 1582 # 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 niro 218
28 niro 343 # which input devices are we using ?
29     ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")
30 niro 1800 ALX_MOUSE_RESOLUTION=$(mysqldo "select mouse_resolution from cfg_input where serial='${ALX_SERIAL}'")
31 niro 218 export ALX_MOUSE
32     }
33    
34 niro 1703 config_display_manager()
35     {
36     # setup slim
37     cat ${ALX_SKELETONS}/slim/slim.conf > /etc/slim.conf
38 niro 1710 sed -i "s:@@USERNAME@@:${ALX_UNPRIV_USER}:" /etc/slim.conf
39 niro 1703
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 niro 2004 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 niro 343 config_x11()
62     {
63 niro 218 # get our settings from the db
64     get_x11_settings
65 niro 1582
66 niro 1703 # setup displaymanager
67     config_display_manager
68    
69 niro 2004 local xserver=Xorg
70 niro 1586 local HAS_TIGERVNC
71 niro 218
72 niro 343 # got we vnc support ?
73 niro 1589 if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ]
74 niro 1586 then
75     HAS_TIGERVNC="yes"
76     else
77     HAS_TIGERVNC="no"
78     fi
79 niro 325
80 niro 343 # show which server we use
81 niro 2004 echo -en ${COLOREDSTAR}"Configuring Xorg x11-server "
82 niro 218
83 niro 343 # show if we have vnc
84 niro 2004 if [[ ${HAS_TIGERVNC} = yes ]]
85 niro 218 then
86 niro 1586 echo "with tigervnc enabled ..."
87 niro 218 else
88     echo "..."
89     fi
90    
91 niro 343 # create a new clear xfconfig file
92 niro 2004 clearconfig
93     addconfig '# Generated with alxconfig-ng.'
94     addconfig
95 niro 218
96 niro 343 # write modules
97 niro 2004 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 niro 218
107 niro 2004 [[ ${HAS_TIGERVNC} = yes ]] && addconfig ' Load "vnc"'
108 niro 218
109 niro 2004 addconfig 'EndSection'
110 niro 218
111 niro 343 # fonts
112 niro 2004 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 niro 218
125 niro 343 # server flags
126 niro 2004 addconfig
127     addconfig 'Section "ServerFlags"'
128     addconfig '# Option "DontVTSwitch"'
129     addconfig '# Option "DontZap"'
130     addconfig '# Option "Dont Zoom"'
131     addconfig 'EndSection'
132 niro 218
133 niro 343 # keyboard
134 niro 2004 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 niro 218
145 niro 343 # mouse
146 niro 2004 addconfig
147     addconfig 'Section "InputDevice"'
148     addconfig ' Identifier "Mouse1"'
149     addconfig ' Driver "mouse"'
150     addconfig " Option \"Protocol\" \"${ALX_MOUSE}\""
151 niro 218 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 niro 2004 addconfig " Option \"Device\" \"${device}\""
158 niro 1800 [[ -z ${ALX_MOUSE_RESOLUTION} ]] && ALX_MOUSE_RESOLUTION="1200"
159 niro 2004 addconfig " Option \"Resolution\" \"${ALX_MOUSE_RESOLUTION}\""
160     [[ ${ALX_MOUSE} = IMPS/2 ]] && addconfig ' Option "ZAxisMapping" "4 5"'
161     addconfig 'EndSection' >> ${xfconfig}
162 niro 1800
163 niro 343 # monitor
164 niro 2004 addconfig
165     addconfig 'Section "Monitor"'
166     addconfig ' Identifier "Monitor0"'
167     addconfig ' Option "DPMS"'
168 niro 1647
169     # add hsync, vrefresh
170     if [[ -x /sbin/ddcxinfo-knoppix ]]
171     then
172 niro 1653 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 niro 2004 addconfig
179     addconfig " HorizSync ${hsync}"
180     addconfig " VertRefresh ${vsync}"
181 niro 1647 fi
182    
183     # add cvt modelines
184 niro 2004 addconfig
185 niro 1582 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 niro 2004 addconfig "${modeline}"
189 niro 1641 # add ddcxinfo-knoppix modelines (fallback)
190 niro 1647 if [[ -x /sbin/ddcxinfo-knoppix ]]
191     then
192 niro 2004 addconfig
193     addconfig $(ddcxinfo-knoppix -modelines)
194 niro 1647 fi
195 niro 2004 addconfig 'EndSection'
196 niro 218
197 niro 343 # vga
198 niro 2004 addconfig
199     addconfig 'Section "Device"'
200     addconfig ' Identifier "vga0"'
201 niro 1620 # 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 niro 2004 addconfig " Driver \"${ALX_MODULE}\""
207     addconfig 'EndSection'
208 niro 218
209 niro 343 # screens
210 niro 2004 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 niro 325 then
223 niro 2004 addconfig ' Option "SecurityTypes" "VncAuth"'
224     addconfig ' Option "UserPasswdVerifier" "VncAuth"'
225     addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
226 niro 325 fi
227 niro 2004 addconfig 'EndSection'
228 niro 218
229 niro 343 # server layout
230 niro 2004 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 niro 218
238 niro 1582 # dri
239 niro 2004 addconfig
240     addconfig 'Section "DRI"' >> ${xfconfig}
241     addconfig ' Mode 0666' >> ${xfconfig}
242     addconfig 'EndSection' >> ${xfconfig}
243 niro 218 }