#!/bin/bash PATH="/bin:/usr/bin:/sbin:/usr/sbin"; export PATH umask 022 # [ "`id -u`" != "0" ] && echo "WARNING: $0 has to run as root to work properly." 1>&2 # ANSI COLORS CRE=" " NORMAL="" # RED: Failure or error message RED="" # GREEN: Success message GREEN="" # YELLOW: Descriptions YELLOW="" # BLUE: System messages BLUE="" # MAGENTA: Found devices or drivers MAGENTA="" # CYAN: Questions CYAN="" # BOLD WHITE: Hint WHITE="" TMPFILE="/tmp/mkxf86config-$$" MONITORTMP="$TMPFILE-monitor" rm -f "$TMPFILE" "$MONITORTMP" ### Utility Function(s) KVER="$(uname -r)" # Reread boot command line; echo last parameter's argument or return false. CMDLINE=" $(cat /proc/cmdline) " getbootparam(){ case "$CMDLINE" in *\ $1=*) ;; *) return 1; ;; esac result="${CMDLINE##*$1=}" result="${result%%[ ]*}" echo "$result" return 0 } checkbootparam(){ case "$CMDLINE" in *\ $1*) return 0;; esac return 1 } # Read in what hwsetup has found for X [ -f /etc/sysconfig/xserver ] && . /etc/sysconfig/xserver # Xserver, Xmodule, Xscreen, Xvrefresh, if specified by commandline NEWXSERVER="$(getbootparam xserver 2>/dev/null)" [ -z "$XSERVER" -a -z "$NEWXSERVER" ] && NEWXSERVER="XFree86" [ -n "$NEWXSERVER" ] && { XSERVER="$NEWXSERVER" ; echo "XSERVER='$XSERVER'" >> /etc/sysconfig/knoppix ; echo "XSERVER='$XSERVER'" >> /etc/sysconfig/xserver; } NEWXMODULE="$(getbootparam xmodule 2>/dev/null)" [ -z "$XMODULE" -a -z "$NEWXMODULE" ] && NEWXMODULE="vesa" [ -n "$NEWXMODULE" ] && { XMODULE="$NEWXMODULE" ; echo "XMODULE='$XMODULE'" >> /etc/sysconfig/knoppix ; echo "XMODULE='$XMODULE'" >> /etc/sysconfig/xserver; } XSCREEN="$(getbootparam xscreen 2>/dev/null)" [ -z "$XSCREEN" ] && XSCREEN="$(getbootparam screen 2>/dev/null)" [ -n "$XSCREEN" ] && { echo "XSCREEN='$XSCREEN'" >> /etc/sysconfig/knoppix ; echo "XSCREEN='$XSCREEN'" >> /etc/sysconfig/xserver; } XVREFRESH="$(getbootparam xvrefresh 2>/dev/null)" [ -n "$XVREFRESH" ] || XVREFRESH="$(getbootparam vrefresh 2>/dev/null)" [ -n "$XVREFRESH" ] || XVREFRESH="$(getbootparam xvsync 2>/dev/null)" [ -n "$XVREFRESH" ] || XVREFRESH="$(getbootparam vsync 2>/dev/null)" [ -n "$XVREFRESH" ] && { echo "XVREFRESH='$XVREFRESH'" >> /etc/sysconfig/knoppix ; echo "XVREFRESH='$XVREFRESH'" >> /etc/sysconfig/xserver; } XHREFRESH="$(getbootparam xhrefresh 2>/dev/null)" [ -n "$XHREFRESH" ] || XHREFRESH="$(getbootparam hrefresh 2>/dev/null)" [ -n "$XHREFRESH" ] || XHREFRESH="$(getbootparam xhsync 2>/dev/null)" [ -n "$XHREFRESH" ] || XHREFRESH="$(getbootparam hsync 2>/dev/null)" [ -n "$XHREFRESH" ] && { echo "XHREFRESH='$XHREFRESH'" >> /etc/sysconfig/knoppix ; echo "XHREFRESH='$XHREFRESH'" >> /etc/sysconfig/xserver; } XDEPTH="$(getbootparam xdepth 2>/dev/null)" [ -n "$XDEPTH" ] || XDEPTH="$(getbootparam depth 2>/dev/null)" [ -n "$XDEPTH" ] && { echo "XDEPTH='$XDEPTH'" >> /etc/sysconfig/knoppix ; echo "XDEPTH='$XDEPTH'" >> /etc/sysconfig/xserver; } # Wheel WHEEL="" if checkbootparam "wheel"; then WHEEL='s|"PS/2"|"IMPS/2"\ Option "ZAxisMapping" "4 5"|g;' elif checkbootparam "nowheel"; then # Don't change the default, which is plain PS/2 WHEEL="" else # Apparently, the mouse auto-protocol option works in XFree 4.3 now. Let's give it a try. WHEEL='s|"PS/2"|"auto"\ Option "ZAxisMapping" "4 5"|g;' fi # Read in changes [ -f /etc/sysconfig/knoppix ] && . /etc/sysconfig/knoppix # Read default keyboard from config file. # There seems to be no reliable autoprobe possible. [ -f /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard # Create mouse link and insert a mouse default type into XF86Config # if not already done by hwsetup [ -f /etc/sysconfig/mouse ] && . /etc/sysconfig/mouse [ -e /dev/mouse ] || ln -sf /dev/ttyS0 /dev/mouse # PROTO="${XMOUSETYPE:-Auto}" PROTO="${XMOUSETYPE:-Microsoft}" NOEMU="" [ "${XEMU3}" = "no" ] && NOEMU='s|^.*Emulate3|# No 2 -> 3 Button emulation|g' DEADKEYS="" [ "$XKEYBOARD" = "de" ] || DEADKEYS='s|^.*nodeadkeys.*$||g;' if [ -n "XMODULE" ]; then # Check for Framebuffer X-Modules and initialize framebuffer module case "$XMODULE" in pvr2fb) modprobe "$XMODULE" >/dev/null 2>&1 ; XMODULE="fbdev"; ;; esac fi NODDC="" checkbootparam noddc && NODDC="true" MONITOR="" COMPLETE="" RC="" if [ -z "$NODDC" ]; then # Try to get Monitor data via ddcxinfo-knoppix MONITOR="$(ddcxinfo-knoppix -monitor)" RC="$?" COMPLETE="$(awk '/EndSection/{print}' <"$MONITORTMP" # /etc/X11/XF86Config* is the "default" config. if [ ! -f /etc/XF86Config -a ! -f /etc/X11/XF86Config ]; then # Remove it, just in case it's a link to CD rm -f /etc/XF86Config /etc/X11/XF86Config 2>/dev/null sed -e 's|@@PROTOCOL@@|'"$PROTO"'|g;'"$NOEMU" \ -e '/@@MONITOR@@/r '"$MONITORTMP" \ -e 's|@@MONITOR@@||g' \ -e 's|@@MODES@@|'"$MODES"'|g;'"$DEPTH" \ -e 's|XkbLayout *"[^"]*"|XkbLayout "'"$XKEYBOARD"'"|g;'"$DEADKEYS" \ /etc/X11/XF86Config.in > /etc/X11/XF86Config fi if [ ! -f /etc/XF86Config-4 -a ! -f /etc/X11/XF86Config-4 ]; then rm -f /etc/XF86Config-4 /etc/X11/XF86Config-4 2>/dev/null # VMWare special handling VMWARE="" if [ "$XMODULE" = "vmware" ]; then VMWARE='s|^.*BusID.*PCI.*$|BusID "PCI:0:15:0"|g;' DEPTH='s|DefaultColorDepth |# DefaultColorDepth |g;' fi # Do NOT use a default colordepth setting if we are using the "fbdev" module if [ "$XMODULE" = "fbdev" ]; then DEPTH='s|DefaultColorDepth |# DefaultColorDepth |g;' fi # These drivers need the sw_cursor option SWCURSOR="" case "$XMODULE" in ati|radeon|nv|trident) SWCURSOR='s|^.*#Option.*"sw_cursor".*$|Option "sw_cursor"|g;';; esac # We must use NoPM, because some machines freeze if Power management is being activated. NOPM="" DPMS="" checkbootparam noapm && NOPM='Option "NoPM" "true"' || DPMS='Option "DPMS" "true"' sed -e 's|@@PROTOCOL@@|'"$PROTO"'|g;'"$NOEMU" \ -e '/@@MONITOR@@/r '"$MONITORTMP" \ -e 's|@@MONITOR@@||g' \ -e 's|@@NOPM@@|'"$NOPM"'|g' \ -e 's|@@XMODULE@@|'"$XMODULE"'|g;'"$VMWARE""$SERIALMOUSE""$USBMOUSE""$PSMOUSE""$SWCURSOR""$WHEEL" \ -e 's|@@MODES@@|'"$MODES"'|g;'"$DEPTH" \ -e 's|"XkbLayout" *"[^"]*"|"XkbLayout" "'"$XKEYBOARD"'"|g;'"$DEADKEYS" \ /etc/X11/XF86Config-4.in >/etc/X11/XF86Config-4 if [ -n "$DPMS" ]; then sed -e 's|Identifier[ ]*"Monitor0"|Identifier "Monitor0"\ '"$DPMS"'|g' /etc/X11/XF86Config-4 >/etc/X11/XF86Config-4.new mv -f /etc/X11/XF86Config-4.new /etc/X11/XF86Config-4 fi fi rm -f "$TMPFILE" "$MONITORTMP" 2>/dev/null # Print info about selected X-Server [ -n "$XDESC" ] || XDESC="(yet) unknown card" echo -n " ${GREEN}Video is" [ -n "$XDESC" ] && echo -n " ${YELLOW}$XDESC${GREEN}," echo -n " using ${YELLOW}${XSERVER:-generic VESA}" [ -n "$XMODULE" ] && echo -n "(${MAGENTA}$XMODULE${YELLOW})" echo " Server${NORMAL}" echo -n " ${GREEN}Monitor is ${YELLOW}${MODEL:-Generic Monitor}${NORMAL}" [ -n "$HREFRESH" -a -n "$VREFRESH" ] && echo "${GREEN}, ${GREEN}H:${YELLOW}${HREFRESH}kHz${GREEN}, V:${YELLOW}${VREFRESH}Hz${NORMAL}" || echo "" [ -n "$XVREFRESH" ] && echo " ${GREEN}Trying specified vrefresh rate of ${YELLOW}${XVREFRESH}Hz.${NORMAL}" [ -n "$MODES" ] && echo " ${GREEN}Using Modes ${YELLOW}${MODES##Modes }${NORMAL}"