Magellan Linux

Diff of /alx-src/tags/alxconf-0_6_4_5/functions/config_x11.sh

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

alx-src/tags/alxconf_20060908_1/alxconfig-ng/functions/config_x11.sh revision 375, Mon Feb 20 14:49:31 2006 UTC alx-src/branches/alxconf-060/functions/config_x11.sh revision 3478 by niro, Fri Apr 13 18:13:13 2012 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 $  # $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()  config_display_manager()
5  {  {
6   local x i all DB_X11SETTINGS   # setup slim
7     cat ${ALX_SKELETONS}/slim/slim.conf > /etc/slim.conf
8   # autodetect or not ?   sed -i "s:@@USERNAME@@:${ALX_UNPRIV_USER}:" /etc/slim.conf
9   if [ $(mysqldo "select monitorid from cfg_graphic where serial='${ALX_SERIAL}'") -gt 0 ]  
10   then   # windowmanager
11   # settings from db   local CONFIG="${ALX_UNPRIV_HOME}/.xinitrc"
12     clearconfig
13   all=$(mysqldo "select cfg_graphic.module,   addconfig "exec startfluxbox"
  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}';")  
   
  # 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=$(mysqldo "select module,  
  resolution,  
  depth  
  from cfg_graphic where serial='${ALX_SERIAL}'")  
   
  # 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=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")  
  export ALX_MOUSE  
14  }  }
15    
16  config_x11()  config_x11()
17  {  {
18     local has_tigervnc
19     local CONFIG
20    
21   # get our settings from the db   # get our settings from the db
22   get_x11_settings   evaluate_table cfg_graphic
23     evaluate_table cfg_input
  local xserver  
  local xfconfig  
  local HAS_VNC  
  local HAS_REALVNC  
   
  # 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  
24    
25   # got we vnc support ?   # setup displaymanager
26   if [ -f /usr/X11R6/lib/modules/vnc.so ]   config_display_manager
  then  
  HAS_VNC="yes"  
  else  
  HAS_VNC="no"  
  fi  
27    
28   if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]   # got we vnc support ?
29     if [ -f /usr/lib/xorg/modules/extensions/libvnc.so ]
30   then   then
31   HAS_REALVNC="yes"   has_tigervnc="yes"
32   else   else
33   HAS_REALVNC="no"   has_tigervnc="no"
34   fi   fi
35    
36   # show which server we use   # show which server we use
37   echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "   rc_echo -en ${COLOREDSTAR}"Configuring Xorg x11-server "
38    
39   # show if we have vnc   # show if we have vnc
40   if [[ ${HAS_VNC} = yes ]]   if [[ ${has_tigervnc} = yes ]]
  then  
  echo "with vnc enabled ..."  
  elif [[ ${HAS_REALVNC} = yes ]]  
41   then   then
42   echo "with realvnc enabled ..."   rc_echo "with tigervnc enabled ..."
43   else   else
44   echo "..."   rc_echo "..."
45   fi   fi
46    
47   # create a new clear xfconfig file   # set_input_keyboard
48   echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-layout.conf"
49   echo '' >> ${xfconfig}   clearconfig
50     addconfig 'Section "InputClass"'
51   # write modules   addconfig ' Identifier "keyboard layout"'
52   echo '' >> ${xfconfig}   addconfig ' MatchIsKeyboard "on"'
53   echo 'Section "Module"' >> ${xfconfig}   addconfig ' Option "XkbLayout" "de"'
54   echo '    Load        "dbe"' >> ${xfconfig}   addconfig 'EndSection'
55   echo '    SubSection  "extmod"' >> ${xfconfig}  
56   echo '      Option    "omit xfree86-dga"' >> ${xfconfig}   # graphic driver
57   echo '    EndSubSection' >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-device.conf"
58   echo '    Load        "type1"' >> ${xfconfig}   clearconfig
59   echo '    Load        "speedo"' >> ${xfconfig}   addconfig 'Section "Device"'
60   echo '    Load        "freetype"' >> ${xfconfig}   addconfig ' Identifier "Card0"'
61   echo '#    Load        "xtt"' >> ${xfconfig}   addconfig " Driver \"${cfg_graphic_module}\""
62   echo '#    Load       "glx"' >> ${xfconfig}   addconfig 'EndSection'
63   echo '    Load       "dri"' >> ${xfconfig}  
64     # vnc module
65   [[ ${HAS_VNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}   if [[ ${has_tigervnc} = yes ]]
66   [[ ${HAS_REALVNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}   then
67     CONFIG="/etc/X11/xorg.conf.d/25-module.conf"
68   echo 'EndSection' >> ${xfconfig}   clearconfig
69     addconfig 'Section "Module"'
70   # fonts   addconfig ' Load "vnc"'
71   echo '' >> ${xfconfig}   addconfig 'EndSection'
  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}  
   
  echo 'EndSection' >> ${xfconfig}  
   
  # vnc keyboard && mouse  
  if [[ ${HAS_VNC} = yes ]]  
  then  
  echo '' >> ${xfconfig}  
  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}  
72   fi   fi
73    
74   # monitor   # monitor
75   if [ -x "/sbin/ddcxinfo-knoppix" ] &&   CONFIG="/etc/X11/xorg.conf.d/25-monitor.conf"
76     [[ ${ALX_HSYNC} = auto ]] ||   clearconfig
77     [[ ${ALX_VREF} = auto ]]   addconfig 'Section "Monitor"'
78   then   addconfig ' Identifier "Monitor0"'
79   ddcxinfo-knoppix -monitor >> ${xfconfig}   addconfig ' Option     "DPMS"'
80    
81     # add hsync, vrefresh
82     if [[ -x /sbin/ddcxinfo-knoppix ]]
83     then
84     local hsync="$(ddcxinfo-knoppix -hsync)"
85     local vsync="$(ddcxinfo-knoppix -vsync)"
86     # fallback
87     [[ ${hsync} = 0-0 ]] && hsync="28-96"
88     [[ ${vsync} = 0-0 ]] && vsync="50-60"
89    
90     addconfig
91     addconfig " HorizSync ${hsync}"
92     addconfig " VertRefresh ${vsync}"
93     fi
94    
95     # add cvt modelines
96     addconfig
97     local cvt="/usr/bin/cvt"
98     local modeline
99     modeline=$("${cvt}" "${cfg_graphic_resolution%x*}" "${cfg_graphic_resolution#*x}" "${cfg_graphic_refresh_rate}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
100     addconfig "${modeline}"
101     # add ddcxinfo-knoppix modelines (fallback)
102     if [[ -x /sbin/ddcxinfo-knoppix ]]
103     then
104     addconfig
105     addconfig $(ddcxinfo-knoppix -modelines)
106     fi
107     addconfig 'EndSection'
108    
109     # screen
110     CONFIG="/etc/X11/xorg.conf.d/25-screen.conf"
111     clearconfig
112     addconfig 'Section "Screen"'
113     addconfig ' Identifier "Screen0"'
114     addconfig ' Monitor "Monitor0"'
115     addconfig " DefaultDepth ${cfg_graphic_depth}"
116     addconfig ' SubSection "Display"'
117     addconfig " Depth ${cfg_graphic_depth}"
118     addconfig " Modes \"${cfg_graphic_resolution}\""
119     addconfig ' ViewPort 0 0'
120     addconfig ' EndSubSection'
121     # vnc auth
122     if [[ ${has_tigervnc} = yes ]]
123     then
124     addconfig ' Option "SecurityTypes" "VncAuth"'
125     addconfig ' Option "UserPasswdVerifier" "VncAuth"'
126     addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
127     fi
128     addconfig 'EndSection'
129    
130     # disable screen blanks, use xscreensaver for it
131     CONFIG="/etc/X11/xorg.conf.d/25-server.conf"
132     clearconfig
133     addconfig 'Section "ServerFlags"'
134     addconfig ' Option "BlankTime" "0"'
135     addconfig ' Option "StandbyTime" "0"'
136     addconfig ' Option "SuspendTime" "0"'
137     addconfig ' Option "OffTime" "0"'
138     addconfig 'EndSection'
139    
140     # fixes
141     # disable LVDS-1 on zotacs or enable it if hdmi was requested
142     if [[ $(alx-hwdetection system) = zotac ]]
143     then
144     CONFIG="/etc/X11/xorg.conf.d/30-fix-zotac.conf"
145     clearconfig
146     addconfig 'Section "Monitor"'
147     addconfig ' Identifier "LVDS1"'
148     if [[ ${cfg_graphic_hdmi} = enable ]]
149     then
150     # add cvt modelines
151     addconfig
152     local cvt="/usr/bin/cvt"
153     local modeline
154     modeline=$("${cvt}" "${cfg_graphic_resolution%x*}" "${cfg_graphic_resolution#*x}" "${cfg_graphic_refresh_rate}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
155     addconfig "${modeline}"
156     else
157     addconfig ' Option "Ignore" "True"'
158     fi
159     addconfig 'EndSection'
160   else   else
161   echo '' >> ${xfconfig}   # clear this file
162   echo "# Monitor: ${ALX_VENDOR} ${ALX_MODEL}" >> ${xfconfig}   if [ -f /etc/X11/xorg.conf.d/30-fix-zotac.conf ]
163   echo 'Section "Monitor"' >> ${xfconfig}   then
164   echo '    Identifier  "Monitor0"' >> ${xfconfig}   rm /etc/X11/xorg.conf.d/30-fix-zotac.conf
165   echo "    HorizSync   ${ALX_HSYNC}" >> ${xfconfig}   fi
  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}  
166   fi   fi
   
  echo 'EndSection' >> ${xfconfig}  
   
  # screens  
  echo '' >> ${xfconfig}  
  echo 'Section "Screen"' >> ${xfconfig}  
  echo '    Identifier  "Screen 1"' >> ${xfconfig}  
  echo '    Device      "vga0"' >> ${xfconfig}  
  echo '    Monitor     "Monitor0"' >> ${xfconfig}  
  echo "    DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}  
  echo '    Subsection "Display"' >> ${xfconfig}  
  echo "        Depth       ${ALX_DEPTH}" >> ${xfconfig}  
  echo "        Modes       \"${ALX_RESOLUTION}\"" >> ${xfconfig}  
  echo '        ViewPort    0 0' >> ${xfconfig}  
  echo '    EndSubsection' >> ${xfconfig}  
   
  if [[ ${HAS_REALVNC} = yes ]]  
  then  
  echo '    Option "SecurityTypes" "VncAuth"' >> ${xfconfig}  
  echo '    Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}  
  echo '    Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}  
  fi  
  echo 'EndSection' >> ${xfconfig}  
   
  # server layout  
  echo '' >> ${xfconfig}  
  echo 'Section "ServerLayout"' >> ${xfconfig}  
  echo '    Identifier  "Simple Layout"' >> ${xfconfig}  
  echo '    Screen "Screen 1"' >> ${xfconfig}  
  echo '    InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}  
  echo '    InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}  
   
  # load vnc keyboard && mouse  
  if [[ ${HAS_VNC} = yes ]]  
  then  
  echo '    InputDevice "vncMouse"    "ExtraPointer"' >> ${xfconfig}  
  echo '    InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}  
  fi  
   
  echo 'EndSection' >> ${xfconfig}  
   
  # dri (here disabled, use default of xserver)  
  echo '' >> ${xfconfig}  
  echo '# Section "DRI"' >> ${xfconfig}  
  echo '#    Mode 0666' >> ${xfconfig}  
  echo '# EndSection' >> ${xfconfig}  
167  }  }
   

Legend:
Removed from v.375  
changed lines
  Added in v.3478