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 1587 by niro, Fri Nov 26 10:41:45 2010 UTC alx-src/branches/alxconf-060/functions/config_x11.sh revision 7967 by niro, Wed Dec 9 10:47:10 2015 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   local CONFIG="${ALX_UNPRIV_HOME}/.xinitrc"
12   from cfg_graphic where serial='${ALX_SERIAL}'")   clearconfig
13     addconfig "exec startfluxbox"
  # 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  
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
24    
25   local xserver   # setup displaymanager
26   local xfconfig   config_display_manager
  local HAS_VNC  
  local HAS_REALVNC  
  local HAS_TIGERVNC  
   
  # 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  
27    
28   # got we vnc support ?   # got we vnc support ?
29   if [ -f /usr/X11R6/lib/modules/vnc.so ]   if [ -f /usr/lib/xorg/modules/extensions/libvnc.so ]
  then  
  HAS_VNC="yes"  
  else  
  HAS_VNC="no"  
  fi  
   
  if [ -f /usr/X11R6/lib/modules/extensions/vnc.so ]  
  then  
  HAS_REALVNC="yes"  
  else  
  HAS_REALVNC="no"  
  fi  
   
  if [ -f /usr/X11R6/lib/modules/extensions/libvnc.so ]  
30   then   then
31   HAS_TIGERVNC="yes"   has_tigervnc="yes"
32   else   else
33   HAS_TIGERVNC="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 ]]  
  then  
  echo "with realvnc enabled ..."  
  elif [[ ${HAS_TIGERVNC} = yes ]]  
41   then   then
42   echo "with tigervnc 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 alxconfig-ng.' > ${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        "freetype"' >> ${xfconfig}   clearconfig
59   echo '#    Load       "glx"' >> ${xfconfig}   addconfig 'Section "Device"'
60   echo '    Load       "dri"' >> ${xfconfig}   addconfig ' Identifier "Card0"'
   
  [[ ${HAS_VNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}  
  [[ ${HAS_REALVNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}  
  [[ ${HAS_TIGERVNC} = yes ]] && echo '    Load       "vnc"' >> ${xfconfig}  
   
  echo 'EndSection' >> ${xfconfig}  
   
  # fonts  
  echo '' >> ${xfconfig}  
  echo 'Section "Files"' >> ${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 '    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}  
61    
62   [[ ${ALX_MOUSE} = IMPS/2 ]] && echo '    Option "ZAxisMapping" "4 5"' >> ${xfconfig}   if [[ $(alx-hwdetection system) = i845 ]]
   
  echo 'EndSection' >> ${xfconfig}  
   
  # vnc keyboard && mouse  
  if [[ ${HAS_VNC} = yes ]]  
63   then   then
64   echo '' >> ${xfconfig}   addconfig ' # i845 hack - using vesa driver atm'
65   echo 'Section "InputDevice"' >> ${xfconfig}   addconfig ' Driver "vesa"'
66   echo '    Identifier "vncKeyboard"' >> ${xfconfig}   else
67   echo '    Driver "rfbkeyb"' >> ${xfconfig}   addconfig " Driver \"${cfg_graphic_module}\""
  echo 'EndSection' >> ${xfconfig}  
   
  echo '' >> ${xfconfig}  
  echo 'Section "InputDevice"' >> ${xfconfig}  
  echo '    Identifier "vncMouse"' >> ${xfconfig}  
  echo '    Driver "rfbmouse"' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
68   fi   fi
69    
70   # monitor   addconfig 'EndSection'
  echo 'Section "Monitor"' >> ${xfconfig}  
  echo '    Identifier  "Monitor0"' >> ${xfconfig}  
  echo '    Option      "DPMS"' >> ${xfconfig}  
  echo '' >> ${xfconfig}  
  # add cvt modelines  
  local cvt="/usr/X11R6/bin/cvt"  
  local modeline  
  modeline=$("${cvt}" "${ALX_RESOLUTION%x*}" "${ALX_RESOLUTION#*x}" "${ALX_REFRESH_RATE}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')  
  echo "${modeline}" >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
   
  # vga  
  echo '' >> ${xfconfig}  
  echo 'Section "Device"' >> ${xfconfig}  
  echo '    Identifier  "vga0"' >> ${xfconfig}  
  echo "    Driver      \"${ALX_MODULE}\"" >> ${xfconfig}  
71    
72   # vnc server options   # vnc module
73   if [[ ${HAS_VNC} = yes ]]   if [[ ${has_tigervnc} = yes ]]
74   then   then
75   echo '' >> ${xfconfig}   CONFIG="/etc/X11/xorg.conf.d/25-module.conf"
76   echo '    # rfb options' >> ${xfconfig}   clearconfig
77   echo '    Option "rfbauth"     "/root/.vnc/passwd"' >> ${xfconfig}   addconfig 'Section "Module"'
78   echo '    Option "rfbport"     "5900"' >> ${xfconfig}   addconfig ' Load "vnc"'
79   echo '    #Option "nevershared"' >> ${xfconfig}   addconfig 'EndSection'
  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}  
80   fi   fi
81    
82   echo 'EndSection' >> ${xfconfig}   # monitor
83     CONFIG="/etc/X11/xorg.conf.d/25-monitor.conf"
84   # screens   clearconfig
85   echo '' >> ${xfconfig}   addconfig 'Section "Monitor"'
86   echo 'Section "Screen"' >> ${xfconfig}   addconfig ' Identifier "Monitor0"'
87   echo '    Identifier  "Screen 1"' >> ${xfconfig}   addconfig ' Option     "DPMS"'
88   echo '    Device      "vga0"' >> ${xfconfig}  
89   echo '    Monitor     "Monitor0"' >> ${xfconfig}   # add hsync, vrefresh
90   echo "    DefaultDepth ${ALX_DEPTH}" >> ${xfconfig}   if [[ -x /sbin/ddcxinfo-knoppix ]]
91   echo '    Subsection "Display"' >> ${xfconfig}   then
92   echo "        Depth       ${ALX_DEPTH}" >> ${xfconfig}   local hsync="$(ddcxinfo-knoppix -hsync)"
93   echo "        Modes       \"${ALX_RESOLUTION}\"" >> ${xfconfig}   local vsync="$(ddcxinfo-knoppix -vsync)"
94   echo '        ViewPort    0 0' >> ${xfconfig}   # fallback
95   echo '    EndSubsection' >> ${xfconfig}   [[ ${hsync} = 0-0 ]] && hsync="28-96"
96     [[ ${vsync} = 0-0 ]] && vsync="50-60"
97   if [[ ${HAS_REALVNC} = yes ]] || [[ ${HAS_TIGERVNC} = yes ]]  
98   then   addconfig
99   echo '    Option "SecurityTypes" "VncAuth"' >> ${xfconfig}   addconfig " HorizSync ${hsync}"
100   echo '    Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig}   addconfig " VertRefresh ${vsync}"
  echo '    Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig}  
101   fi   fi
  echo 'EndSection' >> ${xfconfig}  
102    
103   # server layout   # add cvt modelines
104   echo '' >> ${xfconfig}   addconfig
105   echo 'Section "ServerLayout"' >> ${xfconfig}   local cvt="/usr/bin/cvt"
106   echo '    Identifier  "Simple Layout"' >> ${xfconfig}   local modeline
107   echo '    Screen "Screen 1"' >> ${xfconfig}   modeline=$("${cvt}" "${cfg_graphic_resolution%x*}" "${cfg_graphic_resolution#*x}" "${cfg_graphic_refresh_rate}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
108   echo '    InputDevice "Mouse1" "CorePointer"' >> ${xfconfig}   addconfig "${modeline}"
109   echo '    InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig}   # add ddcxinfo-knoppix modelines (fallback)
110     if [[ -x /sbin/ddcxinfo-knoppix ]]
111   # load vnc keyboard && mouse   then
112   if [[ ${HAS_VNC} = yes ]]   addconfig
113   then   addconfig $(ddcxinfo-knoppix -modelines)
114   echo '    InputDevice "vncMouse"    "ExtraPointer"' >> ${xfconfig}   fi
115   echo '    InputDevice "vncKeyboard" "ExtraKeyboard"' >> ${xfconfig}   addconfig 'EndSection'
116    
117     # screen
118     CONFIG="/etc/X11/xorg.conf.d/25-screen.conf"
119     clearconfig
120     addconfig 'Section "Screen"'
121     addconfig ' Identifier "Screen0"'
122     addconfig ' Monitor "Monitor0"'
123     addconfig " DefaultDepth ${cfg_graphic_depth}"
124     addconfig ' SubSection "Display"'
125     addconfig " Depth ${cfg_graphic_depth}"
126     addconfig " Modes \"${cfg_graphic_resolution}\""
127     addconfig ' ViewPort 0 0'
128     addconfig ' EndSubSection'
129     # vnc auth
130     if [[ ${has_tigervnc} = yes ]]
131     then
132     addconfig ' Option "SecurityTypes" "VncAuth"'
133     addconfig ' Option "UserPasswdVerifier" "VncAuth"'
134     addconfig ' Option "PasswordFile" "/root/.vnc/passwd"'
135     fi
136     addconfig 'EndSection'
137    
138     # disable screen blanks, use xscreensaver for it
139     CONFIG="/etc/X11/xorg.conf.d/25-server.conf"
140     clearconfig
141     addconfig 'Section "ServerFlags"'
142     addconfig ' Option "BlankTime" "0"'
143     addconfig ' Option "StandbyTime" "0"'
144     addconfig ' Option "SuspendTime" "0"'
145     addconfig ' Option "OffTime" "0"'
146     addconfig 'EndSection'
147    
148     # fixes
149     # disable LVDS-1 on zotacs or enable it if hdmi was requested
150     if [[ $(alx-hwdetection system) = zotac ]]
151     then
152     CONFIG="/etc/X11/xorg.conf.d/30-fix-zotac.conf"
153     clearconfig
154     addconfig 'Section "Monitor"'
155     addconfig ' Identifier "LVDS1"'
156     if [[ ${cfg_graphic_hdmi} = enable ]]
157     then
158     # add cvt modelines
159     addconfig
160     local cvt="/usr/bin/cvt"
161     local modeline
162     modeline=$("${cvt}" "${cfg_graphic_resolution%x*}" "${cfg_graphic_resolution#*x}" "${cfg_graphic_refresh_rate}" | sed -e 's:^:\t:g' -e 's:_.*\":\":')
163     addconfig "${modeline}"
164     else
165     addconfig ' Option "Ignore" "True"'
166     fi
167     addconfig 'EndSection'
168     else
169     # clear this file
170     if [ -f /etc/X11/xorg.conf.d/30-fix-zotac.conf ]
171     then
172     rm /etc/X11/xorg.conf.d/30-fix-zotac.conf
173     fi
174   fi   fi
   
  echo 'EndSection' >> ${xfconfig}  
   
  # dri  
  echo '' >> ${xfconfig}  
  echo 'Section "DRI"' >> ${xfconfig}  
  echo '    Mode 0666' >> ${xfconfig}  
  echo 'EndSection' >> ${xfconfig}  
175  }  }
   

Legend:
Removed from v.1587  
changed lines
  Added in v.7967