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/branches/alxconf_20060908/functions/config_x11.sh revision 1582 by niro, Tue Nov 23 12:24:14 2010 UTC alx-src/branches/alxconf-060/functions/config_x11.sh revision 2148 by niro, Tue May 17 11:46:16 2011 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   # autodetect   cat ${ALX_SKELETONS}/slim/slim.conf > /etc/slim.conf
8   all=$(mysqldo "select module,   sed -i "s:@@USERNAME@@:${ALX_UNPRIV_USER}:" /etc/slim.conf
9   resolution,  
10   depth,   # windowmanager
11   refresh_rate   echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc
  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_REFRESH_RATE="${DB_X11SETTINGS[3]:=NULL}"  
   
  # which input devices are we using ?  
  ALX_MOUSE=$(mysqldo "select mouse from cfg_input where serial='${ALX_SERIAL}'")  
  export ALX_MOUSE  
12  }  }
13    
14  config_x11()  config_x11()
15  {  {
16     local has_tigervnc
17     local CONFIG
18    
19   # get our settings from the db   # get our settings from the db
20   get_x11_settings   evaluate_table cfg_graphic
21     evaluate_table cfg_input
22    
23   local xserver   # setup displaymanager
24   local xfconfig   config_display_manager
  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  
25    
26   # got we vnc support ?   # got we vnc support ?
27   if [ -f /usr/X11R6/lib/modules/vnc.so ]   if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ]
28   then   then
29   HAS_VNC="yes"   has_tigervnc="yes"
30   else   else
31   HAS_VNC="no"   has_tigervnc="no"
  fi  
   
  if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]  
  then  
  HAS_REALVNC="yes"  
  else  
  HAS_REALVNC="no"  
32   fi   fi
33    
34   # show which server we use   # show which server we use
35   echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server "   echo -en ${COLOREDSTAR}"Configuring Xorg x11-server "
36    
37   # show if we have vnc   # show if we have vnc
38   if [[ ${HAS_VNC} = yes ]]   if [[ ${has_tigervnc} = yes ]]
  then  
  echo "with vnc enabled ..."  
  elif [[ ${HAS_REALVNC} = yes ]]  
39   then   then
40   echo "with realvnc enabled ..."   echo "with tigervnc enabled ..."
41   else   else
42   echo "..."   echo "..."
43   fi   fi
44    
45   # create a new clear xfconfig file   # set_input_keyboard
46   echo '# Generated with alxconfig-ng.' > ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-layout.conf"
47   echo '' >> ${xfconfig}   clearconfig
48     addconfig 'Section "InputClass"'
49   # write modules   addconfig ' Identifier "keyboard layout"'
50   echo '' >> ${xfconfig}   addconfig ' MatchIsKeyboard "on"'
51   echo 'Section "Module"' >> ${xfconfig}   addconfig ' Option "XkbLayout" "de"'
52   echo '    Load        "dbe"' >> ${xfconfig}   addconfig 'EndSection'
53   echo '    SubSection  "extmod"' >> ${xfconfig}  
54   echo '      Option    "omit xfree86-dga"' >> ${xfconfig}   # graphic driver
55   echo '    EndSubSection' >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-device.conf"
56   echo '    Load        "freetype"' >> ${xfconfig}   clearconfig
57   echo '#    Load       "glx"' >> ${xfconfig}   addconfig 'Section "Device"'
58   echo '    Load       "dri"' >> ${xfconfig}   addconfig ' Identifier "Card0"'
59     addconfig " Driver \"${cfg_graphic_module}\""
60   [[ ${HAS_VNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}   addconfig 'EndSection'
61   [[ ${HAS_REALVNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}  
62     # vnc module
63   echo 'EndSection' >> ${xfconfig}   if [[ ${has_tigervnc} = yes ]]
64     then
65   # fonts   CONFIG="/etc/X11/xorg.conf.d/25-module.conf"
66   echo '' >> ${xfconfig}   clearconfig
67   echo 'Section "Files"' >> ${xfconfig}   addconfig 'Section "Module"'
68     addconfig ' Load vnc'
69   case ${xserver} in   addconfig 'EndSection'
  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 '    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 '    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 '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}  
70   fi   fi
71    
72   # monitor   # monitor
73   echo 'Section "Monitor"' >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-monitor.conf"
74   echo '    Identifier  "Monitor0"' >> ${xfconfig}   clearconfig
75   echo '    Option      "DPMS"' >> ${xfconfig}   addconfig 'Section "Monitor"'
76   echo '' >> ${xfconfig}   addconfig ' Identifier "Monitor0"'
77     addconfig ' Option     "DPMS"'
78    
79     # add hsync, vrefresh
80     if [[ -x /sbin/ddcxinfo-knoppix ]]
81     then
82     local hsync="$(ddcxinfo-knoppix -hsync)"
83     local vsync="$(ddcxinfo-knoppix -vsync)"
84     # fallback
85     [[ ${hsync} = 0-0 ]] && hsync="28-96"
86     [[ ${vsync} = 0-0 ]] && vsync="50-60"
87    
88     addconfig
89     addconfig " HorizSync ${hsync}"
90     addconfig " VertRefresh ${vsync}"
91     fi
92    
93   # add cvt modelines   # add cvt modelines
94     addconfig
95   local cvt="/usr/X11R6/bin/cvt"   local cvt="/usr/X11R6/bin/cvt"
96   local modeline   local modeline
97   modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')   modeline=$("${cvt}" "${cfg_graphic_resolution%x*}" "${cfg_graphic_resolution#*x}" "${cfg_graphic_refresh_rate}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
98   echo "${modeline}" >> ${xfconfig}   addconfig "${modeline}"
99   echo 'EndSection' >> ${xfconfig}   # add ddcxinfo-knoppix modelines (fallback)
100     if [[ -x /sbin/ddcxinfo-knoppix ]]
101   # vga   then
102   echo '' >> ${xfconfig}   addconfig
103   echo 'Section "Device"' >> ${xfconfig}   addconfig $(ddcxinfo-knoppix -modelines)
104   echo '    Identifier  "vga0"' >> ${xfconfig}   fi
105   echo "    Driver      \"${ALX_MODULE}\"" >> ${xfconfig}   addconfig 'EndSection'
106    
107   # vnc server options   # screen
108   if [[ ${HAS_VNC} = yes ]]   CONFIG="/etc/X11/xorg.conf.d/25-screen.conf"
109   then   clearconfig
110   echo '' >> ${xfconfig}   addconfig 'Section "Screen"'
111   echo '    # rfb options' >> ${xfconfig}   addconfig ' Identifier "Screen0"'
112   echo '    Option "rfbauth"     "/root/.vnc/passwd"' >> ${xfconfig}   addconfig ' Monitor "Monitor0"'
113   echo '    Option "rfbport"     "5900"' >> ${xfconfig}   addconfig " DefaultDepth ${cfg_graphic_depth}"
114   echo '    #Option "nevershared"' >> ${xfconfig}   addconfig ' SubSection "Display"'
115   echo '    Option "alwaysshared"' >> ${xfconfig}   addconfig " Depth ${cfg_graphic_depth}"
116   echo '    Option "dontdisconnect"' >> ${xfconfig}   addconfig " Modes \"${cfg_graphic_resolution}\""
117   echo '    Option "httpdir"     "/usr/share/vnc/classes"' >> ${xfconfig}   addconfig ' ViewPort 0 0'
118   echo '    Option "httpport"    "5800"' >> ${xfconfig}   addconfig ' EndSubSection'
119   echo '    # Option "useraccept"' >> ${xfconfig}   # vnc auth
120   echo '    Option "usevnc"' >> ${xfconfig}   if [[ ${has_tigervnc} = yes ]]
121   echo '    # Option "localhost"' >> ${xfconfig}   then
122   echo '    # Option "interface" "192.168.0.1"' >> ${xfconfig}   addconfig ' Option "SecurityTypes" "VncAuth"'
123   echo '    # Option "viewonly"' >> ${xfconfig}   addconfig ' Option "UserPasswdVerifier" "VncAuth"'
124   echo '    # Option "loginauth"' >> ${xfconfig}   addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
  echo '' >> ${xfconfig}  
  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}  
125   fi   fi
126     addconfig 'EndSection'
  echo 'EndSection' >> ${xfconfig}  
   
  # dri  
  echo '' >> ${xfconfig}  
  echo 'Section "DRI"' >> ${xfconfig}  
  echo '    Mode 0666' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
127  }  }
   

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