Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

alx-src/trunk/alxconfig-ng/functions/config_x11.sh revision 219 by niro, Tue Mar 8 20:42:05 2005 UTC alx-src/branches/alxconf_20060908/functions/config_x11.sh revision 1582 by niro, Tue Nov 23 12:24:14 2010 UTC
# Line 1  Line 1 
1    # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_x11.sh,v 1.9 2005-10-09 21:31:54 niro Exp $
2  # configures the x11 server on the host via mysql db settings  # configures the x11 server on the host via mysql db settings
 # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_x11.sh,v 1.2 2005-03-08 20:42:05 niro Exp $  
3    
4  get_x11_settings()  get_x11_settings()
5  {  {
6   local x i all DB_X11SETTINGS   local x i all DB_X11SETTINGS
7     # autodetect
8   # autodetect or not ?   all=$(mysqldo "select module,
9   if [ $(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   resolution,
10   "select monitorid from cfg_graphic where serial='${ALX_SERIAL}") -gt 0 ]   depth,
11   then   refresh_rate
12   # settings from db   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   all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   # which input devices are we using ?
29   "select cfg_graphic.module,   ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")
  cfg_graphic.resolution,  
  cfg_graphic.depth,  
  list_monitors.vendor,  
  list_monitors.model,  
  list_monitors.hsync,  
  list_monitors.vrefresh  
  from list_monitors  
  inner join cfg_graphic  
  on cfg_graphic.monitorid=list_monitors.id  
  and cfg_graphic.serial='${ALX_SERIAL}';")  
   
  echo "DEBUG: ${all}"  
   
  #split'em up and put 'em in an array  
  declare -i i=0  
  for x in ${all}  
  do  
  DB_X11SETTINGS[${i}]="${x}"  
  ((i++))  
  done  
   
  # and now put them in usable var names and export them systemwide  
  export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"  
  export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"  
  export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"  
  export ALX_VENDOR="${DB_X11SETTINGS[3]:=NULL}"  
  export ALX_MODEL="${DB_X11SETTINGS[4]:=NULL}"  
  export ALX_HSYNC="${DB_X11SETTINGS[5]:=NULL}"  
  export ALX_VREF="${DB_X11SETTINGS[6]:=NULL}"  
  else  
  # autodetect  
  all=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select module,  
  resolution,  
  depth  
  from cfg_graphic where serial='${ALX_SERIAL}'")  
   
  echo "DEBUG: ${all}"  
   
  #split'em up and put 'em in an array  
  declare -i i=0  
  for x in ${all}  
  do  
  DB_X11SETTINGS[${i}]="${x}"  
  ((i++))  
  done  
   
  # and now put them in usable var names and export them systemwide  
  export ALX_MODULE="${DB_X11SETTINGS[0]:=NULL}"  
  export ALX_RESOLUTION="${DB_X11SETTINGS[1]:=NULL}"  
  export ALX_DEPTH="${DB_X11SETTINGS[2]:=NULL}"  
  export ALX_VENDOR="Autodetected"  
  export ALX_MODEL="Monitor"  
  export ALX_HSYNC="auto"  
  export ALX_VREF="auto"  
  fi  
   
  #which input devices are we using ?  
  ALX_MOUSE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \  
  "select mouse from cfg_input where serial='${ALX_SERIAL}'")  
30   export ALX_MOUSE   export ALX_MOUSE
31  }  }
32    
33  write_x11_config() {  config_x11()
34    {
35   # get our settings from the db   # get our settings from the db
36   get_x11_settings   get_x11_settings
37    
  # DEBUG  
  echo "MODULE:     '${ALX_MODULE}'"  
  echo "RESOLUTION: '${ALX_RESOLUTION}'"  
  echo "DEPTH:      '${ALX_DEPTH=}'"  
  echo "VENDOR:     '${ALX_VENDOR}'"  
  echo "MODEL:      '${ALX_MODEL}'"  
  echo "HSYNC:      '${ALX_HSYNC}'"  
  echo "VREF:       '${ALX_VREF}'"  
  echo "MOUSE:      '${ALX_MOUSE}'"  
   
38   local xserver   local xserver
39   local xfconfig   local xfconfig
40   local HAS_VNC   local HAS_VNC
41     local HAS_REALVNC
42    
43   #xfree or xorg ?   # xfree or xorg ?
44   xserver="$(readlink /usr/X11R6/bin/X)"   xserver="$(readlink /usr/X11R6/bin/X)"
45    
46   case ${xserver} in   case ${xserver} in
47   Xorg)   Xorg) xfconfig=/etc/X11/xorg.conf ;;
48   xfconfig=/etc/X11/xorg.conf   XFree86) xfconfig=/etc/X11/XF86Config ;;
49   ;;   *) echo "    Unkown xserver. aborting."; exit 1 ;;
  XFree86)  
  xfconfig=/etc/X11/XF86Config  
  ;;  
  *)  
  echo "    Unkown xserver. aborting."  
  exit 1  
  ;;  
50   esac   esac
51    
52   #got we vnc support ?   # got we vnc support ?
53   if [ -f /usr/X11R6/lib/modules/vnc.so ]   if [ -f /usr/X11R6/lib/modules/vnc.so ]
54   then   then
55   HAS_VNC="yes"   HAS_VNC="yes"
# Line 119  write_x11_config() { Line 57  write_x11_config() {
57   HAS_VNC="no"   HAS_VNC="no"
58   fi   fi
59    
60   #show which server we use   if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]
61     then
62     HAS_REALVNC="yes"
63     else
64     HAS_REALVNC="no"
65     fi
66    
67     # show which server we use
68   echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "   echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "
69    
70   #show if we have vnc   # show if we have vnc
71   if [ "${HAS_VNC}" = "yes" ]   if [[ ${HAS_VNC} = yes ]]
72   then   then
73   echo "with vnc enabled ..."   echo "with vnc enabled ..."
74     elif [[ ${HAS_REALVNC} = yes ]]
75     then
76     echo "with realvnc enabled ..."
77   else   else
78   echo "..."   echo "..."
79   fi   fi
80    
81   #create a new clear xfconfig file   # create a new clear xfconfig file
82   echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig}   echo '# Generated with alxconfig-ng.' > ${xfconfig}
83   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
84    
85   #write modules   # write modules
86   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
87   echo 'Section "Module"' >> ${xfconfig}   echo 'Section "Module"' >> ${xfconfig}
88   echo '    Load        "dbe"' >> ${xfconfig}   echo '    Load        "dbe"' >> ${xfconfig}
89   echo '    SubSection  "extmod"' >> ${xfconfig}   echo '    SubSection  "extmod"' >> ${xfconfig}
90   echo '      Option    "omit xfree86-dga"' >> ${xfconfig}   echo '      Option    "omit xfree86-dga"' >> ${xfconfig}
91   echo '    EndSubSection' >> ${xfconfig}   echo '    EndSubSection' >> ${xfconfig}
  echo '    Load        "type1"' >> ${xfconfig}  
  echo '    Load        "speedo"' >> ${xfconfig}  
92   echo '    Load        "freetype"' >> ${xfconfig}   echo '    Load        "freetype"' >> ${xfconfig}
  echo '#    Load        "xtt"' >> ${xfconfig}  
93   echo '#    Load       "glx"' >> ${xfconfig}   echo '#    Load       "glx"' >> ${xfconfig}
94   echo '    Load       "dri"' >> ${xfconfig}   echo '    Load       "dri"' >> ${xfconfig}
95    
96   [ "${HAS_VNC}" = "yes" ] && echo '    Load       "vnc"' >> ${xfconfig}   [[ ${HAS_VNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}
97     [[ ${HAS_REALVNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}
98    
99   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
100    
101   #fonts   # fonts
102   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
103   echo 'Section "Files"' >> ${xfconfig}   echo 'Section "Files"' >> ${xfconfig}
  echo '    RgbPath "/usr/X11R6/lib/X11/rgb"' >> ${xfconfig}  
104    
105   case ${xserver} in   case ${xserver} in
106   Xorg)   Xorg)
# Line 163  write_x11_config() { Line 108  write_x11_config() {
108   echo '    FontPath   "/usr/share/fonts/misc/"' >> ${xfconfig}   echo '    FontPath   "/usr/share/fonts/misc/"' >> ${xfconfig}
109   echo '    FontPath   "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}   echo '    FontPath   "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig}
110   echo '    FontPath   "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}   echo '    FontPath   "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig}
  echo '    #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}  
  echo '    #FontPath   "/usr/share/fonts/Speedo/"' >> ${xfconfig}  
  echo '    #FontPath   "/usr/share/fonts/Type1/"' >> ${xfconfig}  
111   echo '    FontPath   "/usr/share/fonts/TrueType/"' >> ${xfconfig}   echo '    FontPath   "/usr/share/fonts/TrueType/"' >> ${xfconfig}
112   echo '    FontPath   "/usr/share/fonts/freefont/"' >> ${xfconfig}   echo '    FontPath   "/usr/share/fonts/freefont/"' >> ${xfconfig}
113   echo '    FontPath   "/usr/share/fonts/75dpi/"' >> ${xfconfig}   echo '    FontPath   "/usr/share/fonts/75dpi/"' >> ${xfconfig}
# Line 176  write_x11_config() { Line 118  write_x11_config() {
118   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}
119   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig}   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled"' >> ${xfconfig}
120   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig}   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled"' >> ${xfconfig}
  echo '    #prevents slow startup when disabled -> speedo, type1' >> ${xfconfig}  
  echo '    #FontPath   "/usr/X11R6/lib/X11/fonts/Speedo/"' >> ${xfconfig}  
  echo '    #FontPath   "/usr/X11R6/lib/X11/fonts/Type1/"' >> ${xfconfig}  
121   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}
122   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}
123   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}   echo '    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}
# Line 186  write_x11_config() { Line 125  write_x11_config() {
125   ;;   ;;
126   esac   esac
127    
  echo '#    ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig}  
128   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
129    
130   #server flags   # server flags
131   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
132   echo 'Section "ServerFlags"' >> ${xfconfig}   echo 'Section "ServerFlags"' >> ${xfconfig}
133   echo '#    Option "DontVTSwitch"' >> ${xfconfig}   echo '#    Option "DontVTSwitch"' >> ${xfconfig}
# Line 197  write_x11_config() { Line 135  write_x11_config() {
135   echo '#    Option "Dont Zoom"' >> ${xfconfig}   echo '#    Option "Dont Zoom"' >> ${xfconfig}
136   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
137    
138   #keyboard   # keyboard
139   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
140   echo 'Section "InputDevice"' >> ${xfconfig}   echo 'Section "InputDevice"' >> ${xfconfig}
141   echo '    Identifier "Keyboard1"' >> ${xfconfig}   echo '    Identifier "Keyboard1"' >> ${xfconfig}
142    
143   case ${xserver} in   case ${xserver} in
144   Xorg)   Xorg) echo '    Driver "kbd"' >> ${xfconfig} ;;
145   echo '    Driver "kbd"' >> ${xfconfig}   XFree86) echo '    Driver "Keyboard"' >> ${xfconfig} ;;
  ;;  
  XFree86)  
  echo '    Driver "Keyboard"' >> ${xfconfig}  
  ;;  
146   esac   esac
147    
148   echo '    Option "AutoRepeat" "500 30"' >> ${xfconfig}   echo '    Option "AutoRepeat" "500 30"' >> ${xfconfig}
149   echo '#    Option "Xleds"      "1 2 3"' >> ${xfconfig}   echo '#    Option "Xleds"      "1 2 3"' >> ${xfconfig}
150    
151   case ${xserver} in   case ${xserver} in
152   Xorg)   Xorg) echo '    Option "XkbRules" "xorg"' >> ${xfconfig} ;;
153   echo '    Option "XkbRules" "xorg"' >> ${xfconfig}   XFree86) echo '    Option "XkbRules" "xfree86"' >> ${xfconfig} ;;
  ;;  
  XFree86)  
  echo '    Option "XkbRules" "xfree86"' >> ${xfconfig}  
  ;;  
154   esac   esac
155    
156   echo '    Option "XkbModel" "pc104"' >> ${xfconfig}   echo '    Option "XkbModel" "pc105"' >> ${xfconfig}
157   echo '    Option "XkbLayout" "de"' >> ${xfconfig}   echo '    Option "XkbLayout" "de"' >> ${xfconfig}
158   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
159    
160   #mouse   # mouse
161   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
162   echo 'Section "InputDevice"' >> ${xfconfig}   echo 'Section "InputDevice"' >> ${xfconfig}
163   echo '    Identifier "Mouse1"' >> ${xfconfig}   echo '    Identifier "Mouse1"' >> ${xfconfig}
# Line 240  write_x11_config() { Line 170  write_x11_config() {
170   Auto) device=/dev/mouse;;   Auto) device=/dev/mouse;;
171   *) device=/dev/mouse;;   *) device=/dev/mouse;;
172   esac   esac
173     echo "    Option \"Device\"      \"${device}\"" >> ${xfconfig}
174   echo '    Option "Resolution" "1200"' >> ${xfconfig}   echo '    Option "Resolution" "1200"' >> ${xfconfig}
175    
176   [ "${ALX_MOUSE}" = "IMPS/2" ] && echo '    Option "ZAxisMapping" "4 5"' >> ${xfconfig}   [[ ${ALX_MOUSE} = IMPS/2 ]] && echo '    Option "ZAxisMapping" "4 5"' >> ${xfconfig}
177    
178   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
179    
180   #vnc keyboard && mouse   # vnc keyboard && mouse
181   if [ "${HAS_VNC}" = "yes" ]   if [[ ${HAS_VNC} = yes ]]
182   then   then
183   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
184   echo 'Section "InputDevice"' >> ${xfconfig}   echo 'Section "InputDevice"' >> ${xfconfig}
# Line 263  write_x11_config() { Line 193  write_x11_config() {
193   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
194   fi   fi
195    
196     # monitor
197     echo 'Section "Monitor"' >> ${xfconfig}
198     echo '    Identifier  "Monitor0"' >> ${xfconfig}
199     echo '    Option      "DPMS"' >> ${xfconfig}
200     echo '' >> ${xfconfig}
201     # add cvt modelines
202     local cvt="/usr/X11R6/bin/cvt"
203     local modeline
204     modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
205     echo "${modeline}" >> ${xfconfig}
206     echo 'EndSection' >> ${xfconfig}
207    
208   #monitor   # vga
  if [ -x "/sbin/ddcxinfo-knoppix" ] &&  
    [ "${ALX_HSYNC}" = "auto" ] ||  
    [ "${ALX_VREF}" = "auto" ]  
  then  
  ddcxinfo-knoppix -monitor >> ${xfconfig}  
  else  
  echo '' >> ${xfconfig}  
  echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig}  
  echo 'Section "Monitor"' >> ${xfconfig}  
  echo '    Identifier  "Monitor0"' >> ${xfconfig}  
  echo "    HorizSync   ${ALX_HSYNC}" >> ${xfconfig}  
  echo "    VertRefresh ${ALX_VREF}" >> ${xfconfig}  
  echo '    Option      "DPMS"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
  fi  
   
  #vga  
209   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
210   echo 'Section "Device"' >> ${xfconfig}   echo 'Section "Device"' >> ${xfconfig}
211   echo '    Identifier  "vga0"' >> ${xfconfig}   echo '    Identifier  "vga0"' >> ${xfconfig}
212   echo "    Driver      \"${ALX_MODULE}\"" >> ${xfconfig}   echo "    Driver      \"${ALX_MODULE}\"" >> ${xfconfig}
213    
214   #vnc server options   # vnc server options
215   if [ "${HAS_VNC}" = "yes" ]   if [[ ${HAS_VNC} = yes ]]
216   then   then
217   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
218   echo '    # rfb options' >> ${xfconfig}   echo '    # rfb options' >> ${xfconfig}
# Line 310  write_x11_config() { Line 234  write_x11_config() {
234    
235   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
236    
237   #screens   # screens
238   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
239   echo 'Section "Screen"' >> ${xfconfig}   echo 'Section "Screen"' >> ${xfconfig}
240   echo '    Identifier  "Screen 1"' >> ${xfconfig}   echo '    Identifier  "Screen 1"' >> ${xfconfig}
# Line 322  write_x11_config() { Line 246  write_x11_config() {
246   echo "        Modes       \"${ALX_RESOLUTION}\"" >> ${xfconfig}   echo "        Modes       \"${ALX_RESOLUTION}\"" >> ${xfconfig}
247   echo '        ViewPort    0 0' >> ${xfconfig}   echo '        ViewPort    0 0' >> ${xfconfig}
248   echo '    EndSubsection' >> ${xfconfig}   echo '    EndSubsection' >> ${xfconfig}
249    
250     if [[ ${HAS_REALVNC} = yes ]]
251     then
252     echo '    Option "SecurityTypes" "VncAuth"' >> ${xfconfig}
253     echo '    Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}
254     echo '    Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}
255     fi
256   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
257    
258   #server layout   # server layout
259   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
260   echo 'Section "ServerLayout"' >> ${xfconfig}   echo 'Section "ServerLayout"' >> ${xfconfig}
261   echo '    Identifier  "Simple Layout"' >> ${xfconfig}   echo '    Identifier  "Simple Layout"' >> ${xfconfig}
# Line 332  write_x11_config() { Line 263  write_x11_config() {
263   echo '    InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}   echo '    InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}
264   echo '    InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}   echo '    InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}
265    
266   #load vnc keyboard && mouse   # load vnc keyboard && mouse
267   if [ "${HAS_VNC}" = "yes" ]   if [[ ${HAS_VNC} = yes ]]
268   then   then
269   echo '    InputDevice "vncMouse"    "ExtraPointer"' >> ${xfconfig}   echo '    InputDevice "vncMouse"    "ExtraPointer"' >> ${xfconfig}
270   echo '    InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}   echo '    InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}
# Line 341  write_x11_config() { Line 272  write_x11_config() {
272    
273   echo 'EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
274    
275   #dri (here disabled, use default of xserver)   # dri
276   echo '' >> ${xfconfig}   echo '' >> ${xfconfig}
277   echo '# Section "DRI"' >> ${xfconfig}   echo 'Section "DRI"' >> ${xfconfig}
278   echo '#    Mode 0666' >> ${xfconfig}   echo '    Mode 0666' >> ${xfconfig}
279   echo '# EndSection' >> ${xfconfig}   echo 'EndSection' >> ${xfconfig}
280  }  }
281    

Legend:
Removed from v.219  
changed lines
  Added in v.1582