--- alx-src/branches/alxconf-060/functions/config_x11.sh 2011/04/14 19:29:35 1800 +++ alx-src/branches/alxconf-060/functions/config_x11.sh 2011/05/09 14:57:16 2004 @@ -1,4 +1,4 @@ -# $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$ # configures the x11 server on the host via mysql db settings get_x11_settings() @@ -44,6 +44,20 @@ echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc } +clearconfig() +{ + local xfconfig="/etc/X11/xorg.conf" + :> ${xfconfig} +} + +addconfig() +{ + local value="$@" + local xfconfig="/etc/X11/xorg.conf" + + echo "${value}" >> ${xfconfig} +} + config_x11() { # get our settings from the db @@ -52,36 +66,10 @@ # setup displaymanager config_display_manager - local xserver - local xfconfig - local HAS_VNC - local HAS_REALVNC + local xserver=Xorg 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 - # got we vnc support ? - if [ -f /usr/X11R6/lib/modules/vnc.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/xorg/modules/extensions/libvnc.so ] then HAS_TIGERVNC="yes" @@ -90,16 +78,10 @@ fi # show which server we use - echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server " + echo -en ${COLOREDSTAR}"Configuring Xorg x11-server " # show if we have vnc - if [[ ${HAS_VNC} = yes ]] - then - echo "with vnc enabled ..." - elif [[ ${HAS_REALVNC} = yes ]] - then - echo "with realvnc enabled ..." - elif [[ ${HAS_TIGERVNC} = yes ]] + if [[ ${HAS_TIGERVNC} = yes ]] then echo "with tigervnc enabled ..." else @@ -107,129 +89,82 @@ fi # create a new clear xfconfig file - echo '# Generated with alxconfig-ng.' > ${xfconfig} - echo '' >> ${xfconfig} + clearconfig + addconfig '# Generated with alxconfig-ng.' + addconfig # 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 "freetype"' >> ${xfconfig} - echo '# Load "glx"' >> ${xfconfig} - echo ' Load "dri"' >> ${xfconfig} - - [[ ${HAS_VNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} - [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} - [[ ${HAS_TIGERVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} + addconfig + addconfig 'Section "Module"' + addconfig ' Load "dbe"' + addconfig ' SubSection "extmod"' + addconfig ' Option "omit xfree86-dga"' + addconfig ' EndSubSection' + addconfig ' Load "freetype"' + addconfig '# Load "glx"' + addconfig ' Load "dri"' - echo 'EndSection' >> ${xfconfig} + [[ ${HAS_TIGERVNC} = yes ]] && addconfig ' Load "vnc"' - # fonts - echo '' >> ${xfconfig} - echo 'Section "Files"' >> ${xfconfig} - - case ${xserver} in - Xorg) - # only add existing font pathes - [[ -f /usr/share/fonts/local/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/local/"' >> ${xfconfig} - [[ -f /usr/share/fonts/misc/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/misc/"' >> ${xfconfig} - [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> ${xfconfig} - [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> ${xfconfig} - [[ -f /usr/share/fonts/TrueType/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/TrueType/"' >> ${xfconfig} - [[ -f /usr/share/fonts/freefont/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/freefont/"' >> ${xfconfig} - [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && echo ' FontPath "/usr/share/fonts/75dpi/"' >> ${xfconfig} - [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && 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 + addconfig 'EndSection' - echo 'EndSection' >> ${xfconfig} + # fonts + addconfig + addconfig 'Section "Files"' + # only add existing font pathes + [[ -f /usr/share/fonts/local/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/local/"' + [[ -f /usr/share/fonts/misc/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/misc/"' + [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/75dpi/:unscaled"' + [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/100dpi/:unscaled"' + [[ -f /usr/share/fonts/TrueType/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/TrueType/"' + [[ -f /usr/share/fonts/freefont/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/freefont/"' + [[ -f /usr/share/fonts/75dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/75dpi/"' + [[ -f /usr/share/fonts/100dpi/fonts.dir ]] && addconfig ' FontPath "/usr/share/fonts/100dpi/"' + addconfig 'EndSection' # server flags - echo '' >> ${xfconfig} - echo 'Section "ServerFlags"' >> ${xfconfig} - echo '# Option "DontVTSwitch"' >> ${xfconfig} - echo '# Option "DontZap"' >> ${xfconfig} - echo '# Option "Dont Zoom"' >> ${xfconfig} - echo 'EndSection' >> ${xfconfig} + addconfig + addconfig 'Section "ServerFlags"' + addconfig '# Option "DontVTSwitch"' + addconfig '# Option "DontZap"' + addconfig '# Option "Dont Zoom"' + addconfig 'EndSection' # 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} + addconfig + addconfig 'Section "InputDevice"' + addconfig ' Identifier "Keyboard1"' + addconfig ' Driver "kbd"' + addconfig ' Option "AutoRepeat" "500 30"' + addconfig '# Option "Xleds" "1 2 3"' + addconfig ' Option "XkbRules" "xorg"' + addconfig ' Option "XkbModel" "pc105"' + addconfig ' Option "XkbLayout" "de"' + addconfig 'EndSection' # mouse - echo '' >> ${xfconfig} - echo 'Section "InputDevice"' >> ${xfconfig} - echo ' Identifier "Mouse1"' >> ${xfconfig} - echo ' Driver "mouse"' >> ${xfconfig} - echo " Option \"Protocol\" \"${ALX_MOUSE}\"" >> ${xfconfig} - + addconfig + addconfig 'Section "InputDevice"' + addconfig ' Identifier "Mouse1"' + addconfig ' Driver "mouse"' + addconfig " Option \"Protocol\" \"${ALX_MOUSE}\"" 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} - + addconfig " Option \"Device\" \"${device}\"" [[ -z ${ALX_MOUSE_RESOLUTION} ]] && ALX_MOUSE_RESOLUTION="1200" - echo " Option \"Resolution\" \"${ALX_MOUSE_RESOLUTION}\"" >> ${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} - fi + addconfig " Option \"Resolution\" \"${ALX_MOUSE_RESOLUTION}\"" + [[ ${ALX_MOUSE} = IMPS/2 ]] && addconfig ' Option "ZAxisMapping" "4 5"' + addconfig 'EndSection' >> ${xfconfig} # monitor - echo '' >> ${xfconfig} - echo 'Section "Monitor"' >> ${xfconfig} - echo ' Identifier "Monitor0"' >> ${xfconfig} - echo ' Option "DPMS"' >> ${xfconfig} + addconfig + addconfig 'Section "Monitor"' + addconfig ' Identifier "Monitor0"' + addconfig ' Option "DPMS"' # add hsync, vrefresh if [[ -x /sbin/ddcxinfo-knoppix ]] @@ -240,101 +175,69 @@ [[ ${hsync} = 0-0 ]] && hsync="28-96" [[ ${vsync} = 0-0 ]] && vsync="50-60" - echo '' >> ${xfconfig} - echo " HorizSync ${hsync}" >> ${xfconfig} - echo " VertRefresh ${vsync}" >> ${xfconfig} + addconfig + addconfig " HorizSync ${hsync}" + addconfig " VertRefresh ${vsync}" fi # add cvt modelines - echo '' >> ${xfconfig} + addconfig 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} + addconfig "${modeline}" # add ddcxinfo-knoppix modelines (fallback) if [[ -x /sbin/ddcxinfo-knoppix ]] then - echo '' >> ${xfconfig} - ddcxinfo-knoppix -modelines >> ${xfconfig} + addconfig + addconfig $(ddcxinfo-knoppix -modelines) fi - echo 'EndSection' >> ${xfconfig} + addconfig 'EndSection' # vga - echo '' >> ${xfconfig} - echo 'Section "Device"' >> ${xfconfig} - echo ' Identifier "vga0"' >> ${xfconfig} + addconfig + addconfig 'Section "Device"' + addconfig ' Identifier "vga0"' # check for openchrome and use it if available if [[ ${ALX_MODULE} = via ]] && [ -f /usr/X11R6/lib/xorg/modules/drivers/openchrome_drv.so ] then ALX_MODULE="openchrome" fi - 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} - fi - - echo 'EndSection' >> ${xfconfig} + addconfig " Driver \"${ALX_MODULE}\"" + addconfig 'EndSection' # 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 ]] || [[ ${HAS_TIGERVNC} = yes ]] - then - echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig} - echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig} - echo ' Option "PasswordFile" "/root/.vnc/passwd"' >> ${xfconfig} + addconfig + addconfig 'Section "Screen"' + addconfig ' Identifier "Screen 1"' + addconfig ' Device "vga0"' + addconfig ' Monitor "Monitor0"' + addconfig " DefaultDepth ${ALX_DEPTH}" + addconfig ' Subsection "Display"' + addconfig " Depth ${ALX_DEPTH}" + addconfig " Modes \"${ALX_RESOLUTION}\"" + addconfig ' ViewPort 0 0' + addconfig ' EndSubsection' + if [[ ${HAS_TIGERVNC} = yes ]] + then + addconfig ' Option "SecurityTypes" "VncAuth"' + addconfig ' Option "UserPasswdVerifier" "VncAuth"' + addconfig ' Option "PasswordFile" "/root/.vnc/passwd"' fi - echo 'EndSection' >> ${xfconfig} + addconfig 'EndSection' # 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} + addconfig + addconfig 'Section "ServerLayout"' >> ${xfconfig} + addconfig ' Identifier "Simple Layout"' >> ${xfconfig} + addconfig ' Screen "Screen 1"' >> ${xfconfig} + addconfig ' InputDevice "Mouse1" "CorePointer"' >> ${xfconfig} + addconfig ' InputDevice "Keyboard1" "CoreKeyboard"' >> ${xfconfig} + addconfig 'EndSection' >> ${xfconfig} # dri - echo '' >> ${xfconfig} - echo 'Section "DRI"' >> ${xfconfig} - echo ' Mode 0666' >> ${xfconfig} - echo 'EndSection' >> ${xfconfig} + addconfig + addconfig 'Section "DRI"' >> ${xfconfig} + addconfig ' Mode 0666' >> ${xfconfig} + addconfig 'EndSection' >> ${xfconfig} } -