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 278 by niro, Wed Aug 3 17:57:55 2005 UTC alx-src/branches/alxconf-060/functions/config_x11.sh revision 2037 by niro, Wed May 11 09:14:50 2011 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_x11.sh,v 1.7 2005-08-03 17:57:55 niro Exp $  # $Id$
2  # configures the x11 server on the host via mysql db settings  # configures the x11 server on the host via mysql db settings
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}'")
30   cfg_graphic.resolution,   export ALX_MOUSE
31   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}"  
32    
33   #split'em up and put 'em in an array  config_display_manager()
34   declare -i i=0  {
35   for x in ${all}   # setup slim
36   do   cat ${ALX_SKELETONS}/slim/slim.conf > /etc/slim.conf
37   DB_X11SETTINGS[${i}]="${x}"   sed -i "s:@@USERNAME@@:${ALX_UNPRIV_USER}:" /etc/slim.conf
  ((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  
38    
39   #which input devices are we using ?   # windowmanager
40   ALX_MOUSE=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \   echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc
  "select mouse from cfg_input where serial='${ALX_SERIAL}'")  
  export ALX_MOUSE  
41  }  }
42    
43  config_x11() {  config_x11()
44    {
45     local has_tigervnc
46     local CONFIG
47    
48   # get our settings from the db   # get our settings f2rom the db
49   get_x11_settings   get_x11_settings
   
  # 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}'"  
   
  local xserver  
  local xfconfig  
  local HAS_VNC  
   
  #xfree or xorg ?  
  xserver="$(readlink /usr/X11R6/bin/X)"  
   
  case ${xserver} in  
  Xorg)  
  xfconfig=/etc/X11/xorg.conf  
  ;;  
  XFree86)  
  xfconfig=/etc/X11/XF86Config  
  ;;  
  *)  
  echo "    Unkown xserver. aborting."  
  exit 1  
  ;;  
  esac  
50    
51   #got we vnc support ?   # setup displaymanager
52   if [ -f /usr/X11R6/lib/modules/vnc.so ]   config_display_manager
  then  
  HAS_VNC="yes"  
  else  
  HAS_VNC="no"  
  fi  
53    
54   #show which server we use   # got we vnc support ?
55   echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "   if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ]
   
  #show if we have vnc  
  if [ "${HAS_VNC}" = "yes" ]  
56   then   then
57   echo "with vnc enabled ..."   has_tigervnc="yes"
58   else   else
59   echo "..."   has_tigervnc="no"
60   fi   fi
61    
62   #create a new clear xfconfig file   # show which server we use
63   echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig}   echo -en ${COLOREDSTAR}"Configuring Xorg x11-server "
  echo '' >> ${xfconfig}  
   
  #write modules  
  echo '' >> ${xfconfig}  
  echo 'Section "Module"' >> ${xfconfig}  
  echo '    Load        "dbe"' >> ${xfconfig}  
  echo '    SubSection  "extmod"' >> ${xfconfig}  
  echo '      Option    "omit xfree86-dga"' >> ${xfconfig}  
  echo '    EndSubSection' >> ${xfconfig}  
  echo '    Load        "type1"' >> ${xfconfig}  
  echo '    Load        "speedo"' >> ${xfconfig}  
  echo '    Load        "freetype"' >> ${xfconfig}  
  echo '#    Load        "xtt"' >> ${xfconfig}  
  echo '#    Load       "glx"' >> ${xfconfig}  
  echo '    Load       "dri"' >> ${xfconfig}  
   
  [ "${HAS_VNC}" = "yes" ] && echo '    Load       "vnc"' >> ${xfconfig}  
   
  echo 'EndSection' >> ${xfconfig}  
   
  #fonts  
  echo '' >> ${xfconfig}  
  echo 'Section "Files"' >> ${xfconfig}  
  echo '    RgbPath "/usr/X11R6/lib/X11/rgb"' >> ${xfconfig}  
   
  case ${xserver} in  
  Xorg)  
  echo '    FontPath   "/usr/share/fonts/local/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/share/fonts/misc/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/share/fonts/75dpi/: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}  
  echo '    FontPath   "/usr/share/fonts/TrueType/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/share/fonts/freefont/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/share/fonts/75dpi/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/share/fonts/100dpi/"' >> ${xfconfig}  
  ;;  
  XFree86)  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/local/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/misc/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/: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}  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/TrueType/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/freefont/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/75dpi/"' >> ${xfconfig}  
  echo '    FontPath   "/usr/X11R6/lib/X11/fonts/100dpi/"' >> ${xfconfig}  
  ;;  
  esac  
   
  echo '#    ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
   
  #server flags  
  echo '' >> ${xfconfig}  
  echo 'Section "ServerFlags"' >> ${xfconfig}  
  echo '#    Option "DontVTSwitch"' >> ${xfconfig}  
  echo '#    Option "DontZap"' >> ${xfconfig}  
  echo '#    Option "Dont Zoom"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
   
  #keyboard  
  echo '' >> ${xfconfig}  
  echo 'Section "InputDevice"' >> ${xfconfig}  
  echo '    Identifier "Keyboard1"' >> ${xfconfig}  
   
  case ${xserver} in  
  Xorg)  
  echo '    Driver "kbd"' >> ${xfconfig}  
  ;;  
  XFree86)  
  echo '    Driver "Keyboard"' >> ${xfconfig}  
  ;;  
  esac  
   
  echo '    Option "AutoRepeat" "500 30"' >> ${xfconfig}  
  echo '#    Option "Xleds"      "1 2 3"' >> ${xfconfig}  
   
  case ${xserver} in  
  Xorg)  
  echo '    Option "XkbRules" "xorg"' >> ${xfconfig}  
  ;;  
  XFree86)  
  echo '    Option "XkbRules" "xfree86"' >> ${xfconfig}  
  ;;  
  esac  
   
  echo '    Option "XkbModel" "pc105"' >> ${xfconfig}  
  echo '    Option "XkbLayout" "de"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
   
  #mouse  
  echo '' >> ${xfconfig}  
  echo 'Section "InputDevice"' >> ${xfconfig}  
  echo '    Identifier "Mouse1"' >> ${xfconfig}  
  echo '    Driver "mouse"' >> ${xfconfig}  
  echo "    Option \"Protocol\"    \"${ALX_MOUSE}\"" >> ${xfconfig}  
   
  local device  
  case ${ALX_MOUSE} in  
  IMPS/2|PS/2) device=/dev/psaux;;  
  Auto) device=/dev/mouse;;  
  *) device=/dev/mouse;;  
  esac  
  echo "    Option \"Device\"      \"${device}\"" >> ${xfconfig}  
  echo '    Option "Resolution" "1200"' >> ${xfconfig}  
   
  [ "${ALX_MOUSE}" = "IMPS/2" ] && echo '    Option "ZAxisMapping" "4 5"' >> ${xfconfig}  
64    
65   echo 'EndSection' >> ${xfconfig}   # show if we have vnc
66     if [[ ${has_tigervnc} = yes ]]
  #vnc keyboard && mouse  
  if [ "${HAS_VNC}" = "yes" ]  
67   then   then
68   echo '' >> ${xfconfig}   echo "with tigervnc enabled ..."
  echo 'Section "InputDevice"' >> ${xfconfig}  
  echo '    Identifier "vncKeyboard"' >> ${xfconfig}  
  echo '    Driver "rfbkeyb"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
   
  echo '' >> ${xfconfig}  
  echo 'Section "InputDevice"' >> ${xfconfig}  
  echo '    Identifier "vncMouse"' >> ${xfconfig}  
  echo '    Driver "rfbmouse"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
  fi  
   
   
  #monitor  
  if [ -x "/sbin/ddcxinfo-knoppix" ] &&  
    [ "${ALX_HSYNC}" = "auto" ] ||  
    [ "${ALX_VREF}" = "auto" ]  
  then  
  ddcxinfo-knoppix -monitor >> ${xfconfig}  
69   else   else
70   echo '' >> ${xfconfig}   echo "..."
  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  
  echo '' >> ${xfconfig}  
  echo 'Section "Device"' >> ${xfconfig}  
  echo '    Identifier  "vga0"' >> ${xfconfig}  
  echo "    Driver      \"${ALX_MODULE}\"" >> ${xfconfig}  
   
  #vnc server options  
  if [ "${HAS_VNC}" = "yes" ]  
  then  
  echo '' >> ${xfconfig}  
  echo '    # rfb options' >> ${xfconfig}  
  echo '    Option "rfbauth"     "/root/.vnc/passwd"' >> ${xfconfig}  
  echo '    Option "rfbport"     "5900"' >> ${xfconfig}  
  echo '    #Option "nevershared"' >> ${xfconfig}  
  echo '    Option "alwaysshared"' >> ${xfconfig}  
  echo '    Option "dontdisconnect"' >> ${xfconfig}  
  echo '    Option "httpdir"     "/usr/share/vnc/classes"' >> ${xfconfig}  
  echo '    Option "httpport"    "5800"' >> ${xfconfig}  
  echo '    # Option "useraccept"' >> ${xfconfig}  
  echo '    Option "usevnc"' >> ${xfconfig}  
  echo '    # Option "localhost"' >> ${xfconfig}  
  echo '    # Option "interface" "192.168.0.1"' >> ${xfconfig}  
  echo '    # Option "viewonly"' >> ${xfconfig}  
  echo '    # Option "loginauth"' >> ${xfconfig}  
  echo '' >> ${xfconfig}  
71   fi   fi
72    
73   echo 'EndSection' >> ${xfconfig}   # set_input_keyboard
74     CONFIG="/etc/X11/xorg.conf.d/25-layout.conf"
75   #screens   clearconfig
76   echo '' >> ${xfconfig}   addconfig 'Section "InputClass"'
77   echo 'Section "Screen"' >> ${xfconfig}   addconfig ' Identifier "keyboard layout"'
78   echo '    Identifier  "Screen 1"' >> ${xfconfig}   addconfig ' MatchIsKeyboard "on"'
79   echo '    Device      "vga0"' >> ${xfconfig}   addconfig ' Option "XkbLayout" "de"'
80   echo '    Monitor     "Monitor0"' >> ${xfconfig}   addconfig 'EndSection'
81   echo "    DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}  
82   echo '    Subsection "Display"' >> ${xfconfig}   # graphic driver
83   echo "        Depth       ${ALX_DEPTH}" >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-device.conf"
84   echo "        Modes       \"${ALX_RESOLUTION}\"" >> ${xfconfig}   clearconfig
85   echo '        ViewPort    0 0' >> ${xfconfig}   addconfig 'Section "Device"'
86   echo '    EndSubsection' >> ${xfconfig}   addconfig ' Identifier "Card0"'
87   echo 'EndSection' >> ${xfconfig}   addconfig " Driver \"${ALX_MODULE}\""
88     addconfig 'EndSection'
89   #server layout  
90   echo '' >> ${xfconfig}   # vnc module
91   echo 'Section "ServerLayout"' >> ${xfconfig}   if [[ ${has_tigervnc} = yes ]]
92   echo '    Identifier  "Simple Layout"' >> ${xfconfig}   then
93   echo '    Screen "Screen 1"' >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-module.conf"
94   echo '    InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}   clearconfig
95   echo '    InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}   addconfig 'Section "Module"'
96     addconfig ' Load vnc'
97   #load vnc keyboard && mouse   addconfig 'EndSection'
98   if [ "${HAS_VNC}" = "yes" ]   fi
99   then  
100   echo '    InputDevice "vncMouse"    "ExtraPointer"' >> ${xfconfig}   # monitor
101   echo '    InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-monitor.conf"
102     clearconfig
103     addconfig 'Section "Monitor"'
104     addconfig ' Identifier "Monitor0"'
105     addconfig ' Option     "DPMS"'
106    
107     # add hsync, vrefresh
108     if [[ -x /sbin/ddcxinfo-knoppix ]]
109     then
110     local hsync="$(ddcxinfo-knoppix -hsync)"
111     local vsync="$(ddcxinfo-knoppix -vsync)"
112     # fallback
113     [[ ${hsync} = 0-0 ]] && hsync="28-96"
114     [[ ${vsync} = 0-0 ]] && vsync="50-60"
115    
116     addconfig
117     addconfig " HorizSync ${hsync}"
118     addconfig " VertRefresh ${vsync}"
119     fi
120    
121     # add cvt modelines
122     addconfig
123     local cvt="/usr/X11R6/bin/cvt"
124     local modeline
125     modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
126     addconfig "${modeline}"
127     # add ddcxinfo-knoppix modelines (fallback)
128     if [[ -x /sbin/ddcxinfo-knoppix ]]
129     then
130     addconfig
131     addconfig $(ddcxinfo-knoppix -modelines)
132     fi
133     addconfig 'EndSection'
134    
135     # screen
136     CONFIG="/etc/X11/xorg.conf.d/25-screen.conf"
137     clearconfig
138     addconfig 'Section "Screen"'
139     addconfig ' Identifier "Screen0"'
140     addconfig ' Monitor "Monitor0"'
141     addconfig " DefaultDepth ${ALX_DEPTH}"
142     addconfig ' SubSection "Display"'
143     addconfig " Depth ${ALX_DEPTH}"
144     addconfig " Modes \"${ALX_RESOLUTION}\""
145     addconfig ' ViewPort 0 0'
146     addconfig ' EndSubSection'
147     # vnc auth
148     if [[ ${has_tigervnc} = yes ]]
149     then
150     addconfig ' Option "SecurityTypes" "VncAuth"'
151     addconfig ' Option "UserPasswdVerifier" "VncAuth"'
152     addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
153   fi   fi
154     addconfig 'EndSection'
155    
  echo 'EndSection' >> ${xfconfig}  
   
  #dri (here disabled, use default of xserver)  
  echo '' >> ${xfconfig}  
  echo '# Section "DRI"' >> ${xfconfig}  
  echo '#    Mode 0666' >> ${xfconfig}  
  echo '# EndSection' >> ${xfconfig}  
156  }  }
   

Legend:
Removed from v.278  
changed lines
  Added in v.2037