--- alx-src/tags/alxconf_20060908_1/alxconfig-ng/functions/config_x11.sh 2006/02/20 14:49:31 375 +++ alx-src/branches/alxconf_20060908/functions/config_x11.sh 2011/01/25 00:32:15 1710 @@ -4,94 +4,66 @@ get_x11_settings() { local x i all DB_X11SETTINGS - - # autodetect or not ? - if [ $(mysqldo "select monitorid from cfg_graphic where serial='${ALX_SERIAL}'") -gt 0 ] - then - # settings from db - - all=$(mysqldo "select cfg_graphic.module, - 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 + # autodetect + all=$(mysqldo "select module, + resolution, + depth, + refresh_rate + 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 } +config_display_manager() +{ + # setup slim + cat ${ALX_SKELETONS}/slim/slim.conf > /etc/slim.conf + sed -i "s:@@USERNAME@@:${ALX_UNPRIV_USER}:" /etc/slim.conf + + # setup xession + sed -i "s:\(^GLOGIN=\).*:\1slim:" /etc/rc.config + + # windowmanager + echo "exec startfluxbox" > ${ALX_UNPRIV_HOME}/.xinitrc +} + config_x11() { # get our settings from the db get_x11_settings - + + # setup displaymanager + config_display_manager + local xserver local xfconfig 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 - ;; + Xorg) xfconfig=/etc/X11/xorg.conf ;; + XFree86) xfconfig=/etc/X11/XF86Config ;; + *) echo " Unkown xserver. aborting."; exit 1 ;; esac # got we vnc support ? @@ -109,6 +81,13 @@ HAS_REALVNC="no" fi + if [ -f /usr/X11R6/lib/xorg/modules/extensions/libvnc.so ] + then + HAS_TIGERVNC="yes" + else + HAS_TIGERVNC="no" + fi + # show which server we use echo -en ${COLOREDSTAR}"Using '${xserver}' as x11-server " @@ -119,12 +98,15 @@ elif [[ ${HAS_REALVNC} = yes ]] then echo "with realvnc enabled ..." + elif [[ ${HAS_TIGERVNC} = yes ]] + then + echo "with tigervnc enabled ..." else echo "..." fi # create a new clear xfconfig file - echo '# Generated with hwdetect, part of Magellan-Linux initscripts.' > ${xfconfig} + echo '# Generated with alxconfig-ng.' > ${xfconfig} echo '' >> ${xfconfig} # write modules @@ -134,45 +116,37 @@ 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} [[ ${HAS_REALVNC} = yes ]] && echo ' Load "vnc"' >> ${xfconfig} + [[ ${HAS_TIGERVNC} = 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} + # 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 ' #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} @@ -180,7 +154,6 @@ ;; esac - echo '# ModulePath "/usr/X11R6/lib/modules"' >> ${xfconfig} echo 'EndSection' >> ${xfconfig} # server flags @@ -197,24 +170,16 @@ echo ' Identifier "Keyboard1"' >> ${xfconfig} case ${xserver} in - Xorg) - echo ' Driver "kbd"' >> ${xfconfig} - ;; - XFree86) - echo ' Driver "Keyboard"' >> ${xfconfig} - ;; + 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} - ;; + Xorg) echo ' Option "XkbRules" "xorg"' >> ${xfconfig} ;; + XFree86) echo ' Option "XkbRules" "xfree86"' >> ${xfconfig} ;; esac echo ' Option "XkbModel" "pc105"' >> ${xfconfig} @@ -258,26 +223,48 @@ fi # monitor - if [ -x "/sbin/ddcxinfo-knoppix" ] && - [[ ${ALX_HSYNC} = auto ]] || - [[ ${ALX_VREF} = auto ]] + echo '' >> ${xfconfig} + echo 'Section "Monitor"' >> ${xfconfig} + echo ' Identifier "Monitor0"' >> ${xfconfig} + echo ' Option "DPMS"' >> ${xfconfig} + + # add hsync, vrefresh + if [[ -x /sbin/ddcxinfo-knoppix ]] then - ddcxinfo-knoppix -monitor >> ${xfconfig} - else + local hsync="$(ddcxinfo-knoppix -hsync)" + local vsync="$(ddcxinfo-knoppix -vsync)" + # fallback + [[ ${hsync} = 0-0 ]] && hsync="28-96" + [[ ${vsync} = 0-0 ]] && vsync="50-60" + echo '' >> ${xfconfig} - 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} + echo " HorizSync ${hsync}" >> ${xfconfig} + echo " VertRefresh ${vsync}" >> ${xfconfig} + fi + + # add cvt modelines + echo '' >> ${xfconfig} + 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} + # add ddcxinfo-knoppix modelines (fallback) + if [[ -x /sbin/ddcxinfo-knoppix ]] + then + echo '' >> ${xfconfig} + ddcxinfo-knoppix -modelines >> ${xfconfig} fi + echo 'EndSection' >> ${xfconfig} # vga echo '' >> ${xfconfig} echo 'Section "Device"' >> ${xfconfig} echo ' Identifier "vga0"' >> ${xfconfig} + # 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 @@ -316,7 +303,7 @@ echo ' ViewPort 0 0' >> ${xfconfig} echo ' EndSubsection' >> ${xfconfig} - if [[ ${HAS_REALVNC} = yes ]] + if [[ ${HAS_REALVNC} = yes ]] || [[ ${HAS_TIGERVNC} = yes ]] then echo ' Option "SecurityTypes" "VncAuth"' >> ${xfconfig} echo ' Option "UserPasswdVerifier" "VncAuth"' >> ${xfconfig} @@ -341,10 +328,10 @@ echo 'EndSection' >> ${xfconfig} - # dri (here disabled, use default of xserver) + # dri echo '' >> ${xfconfig} - echo '# Section "DRI"' >> ${xfconfig} - echo '# Mode 0666' >> ${xfconfig} - echo '# EndSection' >> ${xfconfig} + echo 'Section "DRI"' >> ${xfconfig} + echo ' Mode 0666' >> ${xfconfig} + echo 'EndSection' >> ${xfconfig} }