Fix virtualbox config, deactivate type1 and freetype module
[grml-x.git] / grml-x
diff --git a/grml-x b/grml-x
index d5a8f99..6cf4906 100755 (executable)
--- a/grml-x
+++ b/grml-x
@@ -4,7 +4,6 @@
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Don Jul 12 01:20:47 CEST 2007 [mika]
 ################################################################################
 
 # debugging {{{
   [ -n "$XINITRC" ] || XINITRC="$HOME/.xinitrc"
 
   # temporary files
-  HWINFO_TMP="/tmp/hwinfo.$$"
-  MONITORINFO="/tmp/monitorinfo.$$"
-  MOUSEINFO="/tmp/mouse.$$"
+  # notice: we need the unsafe option, otherwise users other than root
+  # can not write to HWINFO_TMP, but we don't want to run hwinfo as root
+  HWINFO_TMP="$(mktemp -u)" || exit 1
+  MONITORINFO="$(mktemp)"   || exit 1
+  MOUSEINFO="$(mktemp)"     || exit 1
+
+  if [ -z "$HWINFO_TMP" ] ; then
+     echo "Fatal: could not create temporary file. Exiting.">&2
+     bailout 1
+  fi
 
   if [ -r /etc/sysconfig/keyboard ] ; then
     source /etc/sysconfig/keyboard
@@ -120,17 +126,17 @@ usage()
 Usage: $PROGRAMNAME
        $PROGRAMNAME [-options] windowmanager
 
-Examples:
-  $PROGRAMNAME wmii
-  $PROGRAMNAME pekwm
+Usage examples:
+  $PROGRAMNAME fluxbox
   $PROGRAMNAME fluxbox
   $PROGRAMNAME -force -nostart fluxbox
   $PROGRAMNAME -nosynaptics fluxbox
   $PROGRAMNAME -nosync fluxbox
-  $PROGRAMNAME -noddc wmii
-  $PROGRAMNAME -module radeon -mode 1024x768 -vsync 60 wmi
-  XINITRC=~/.xinitrc $PROGRAMNAME ion
-  $PROGRAMNAME -display 8 wmii
+  $PROGRAMNAME -noddc fluxbox
+  $PROGRAMNAME -xinerama -composite fluxbox
+  $PROGRAMNAME -module radeon -mode 1024x768 -vsync 60 fluxbox
+  XINITRC=~/.xinitrc $PROGRAMNAME fluxbox
+  $PROGRAMNAME -display 8 fluxbox
 
 More information on grml-x can be found in the manual page: man grml-x
 
@@ -174,23 +180,6 @@ sort -nur | perl -ne 's/\s+/ /; s/(\d+x\d+)/"$1"/; print')
 Option for $fg[yellow]Xinerama$fg[green] found, please use xrandr inside X.org for your further configuration!
 Trying to identify monitors now..."
 
-      # Currently we only know that it works with current intel driver,
-      # so inform user about that:
-      if [[ "$MODULE" != "intel" ]] ; then
-              print "$fg[red]
-
-Warning: using a non-intel driver - trying Xinerama setup anyway.
-If it worked please contact grml developers providing information
-about your setup so we can adjust grml-x according!
-
-      -> http://grml.org/contact/
-
-Sleeping for 10 seconds now... Will continue then...
-Just press Ctrl-C to cancel operation.
-"
-#             sleep 10 # FIXME
-      fi
-
       # make sure we have information from 2 monitors:
       # - first one from 'hwinfo --monitor'      => $MONITORINFO
       # - second one from 'hwinfo --framebuffer' => $FRAMEBUFFER
@@ -200,9 +189,10 @@ Just press Ctrl-C to cancel operation.
 Fatal: could not identify two monitors - no chance to
        set up multihead using Xinerama - sorry. :-(
 
-Please run grml-x without the -xinerama option and contact
-grml developers if you have any further useful information.
-       => http://grml.org/bugs/
+Please run grml-x without the -xinerama option to start
+X anyway (dropping support for Xinerama of course) and
+contact grml developers if you have any further useful
+information.                  => http://grml.org/bugs/
 "
          bailout 10
       fi
@@ -215,15 +205,40 @@ Fatal: could not identify monitor - no chance to
 "
          bailout 11
       else
+         # Currently we only know that it works with current intel driver,
+         # so inform user about that:
+         if [[ "$MODULE" != "intel" ]] ; then
+            print "$fg[red]
+
+Warning: using a non-intel driver - trying Xinerama setup anyway.
+If it worked please contact grml developers providing information
+about your setup so we can adjust grml-x according!
+
+      -> http://grml.org/contact/
+
+Sleeping for 10 seconds now... Will continue then...
+Just press Ctrl-C to cancel operation.
+"
+            sleep 10
+         fi
+
          # now calculate Virtual size for use with Xinerama
          HORIZ_RES1="$(grep 'Max. Resolution:' $MONITORINFO | sed 's/    Max\. Resolution: \(.*\)x\(.*\)/\1/')"
          VERIZ_RES1="$(grep 'Max. Resolution:' $MONITORINFO | sed 's/    Max\. Resolution: \(.*\)x\(.*\)/\2/')"
+        # it might happen that we don't have a Max Resolution in hwinfo output :-/
+         # fall back to a generic value then...
+         # TODO: check out how to get resolution of external monitor from console
+        if [ -z "$HORIZ_RES1" ] ; then
+            HORIZ_RES1="1024"
+            VERIZ_RES1="768"
+         fi
 
-         HORIZ_RES2="$(echo $FRAMEBUFFER | sed 's/  Mode 0x.*: \(.*\)x.*/\1/')"
-         VERIZ_RES2="$(echo $FRAMEBUFFER | sed 's/  Mode 0x.*x\(.*\) (.*/\1/')"
+        # get maximum of output
+         HORIZ_RES2="$(echo $FRAMEBUFFER | grep 'Mode 0x' | sed 's/  Mode 0x.*: \(.*\)x.*/\1/'| sort -u | head -1)"
+         VERIZ_RES2="$(echo $FRAMEBUFFER | grep 'Mode 0x' | sed 's/  Mode 0x.*x\(.*\) (.*/\1/' | sort -u | head -1)"
 
-         if [ -n "$HORIZ_RES1" -a -n "$VERIZ_RES1" -a -n "$HORIZ_RES2" ] ; then
-            if [ $(echo $VERIZ_RES1 - $VERIZ_RES2 | bc -l) -eq 0 ] ; then
+         if [ -n "$HORIZ_RES1" -a -n "$VERIZ_RES1" -a -n "$HORIZ_RES2" -a -n "$VERIZ_RES2" ] ; then
+            if [ "$(echo $VERIZ_RES1" - "$VERIZ_RES2 | bc -l)" -eq 0 ] ; then
             VERIZ_RESULT="$VERIZ_RES1"
             elif [ "$VERIZ_RES1" -gt "$VERIZ_RES2" ] ; then
                VERIZ_RESULT="$VERIZ_RES1"
@@ -236,7 +251,7 @@ Fatal: could not identify monitor - no chance to
             # important: keep newline for appropriate placing below $MODES!
             if [ -n "$HORIZ_RESULT" ] ; then
                VIRTUAL="
-                   Virtual $HORIZ_RESULT $VERIZ_RES1"
+                Virtual $HORIZ_RESULT $VERIZ_RES1"
             fi
          fi
        fi
@@ -256,6 +271,7 @@ Fatal: could not identify monitor - no chance to
 sync()
 {
    [ -r "$MONITORINFO" ] || monitor # get monitor settings
+   [ -r "$MONITORINFO" ] || bailout 1
    vsyncval=$(awk '/Vert. Sync Range:/{print $4}' $MONITORINFO | sed 's/-/.0 - / ; s/$/.0/' | head -1)
    hsyncval=$(awk '/Hor. Sync Range:/{print $4}'  $MONITORINFO | sed 's/-/.0 - / ; s/$/.0/' | head -1)
    if [ -z $vsyncval ] ; then
@@ -276,7 +292,7 @@ mouse()
    if grep -q 'Device:.*Synaptics' "$MOUSEINFO" ; then
     if [[ "$SYNAPTICS" == "yes" ]] ; then # check for '-nosynaptics'-option
      MOUSEDRIVER='synaptics'
-     SYNMOUSE='InputDevice    "Synaptics"  "AlwaysCore"'
+     SYNMOUSE='InputDevice    "Synaptics" # "AlwaysCore"'
      SYNMOUSEDETAIL="
 Section \"InputDevice\"
   Driver        \"synaptics\"
@@ -311,7 +327,7 @@ EndSection
     if grep -q 'Device:.*ALPS' "$MOUSEINFO" ; then
      if [[ "$SYNAPTICS" == "yes" ]] ; then # check for '-nosynaptics'-option
       MOUSEDRIVER='synaptics'
-      SYNMOUSE='InputDevice    "Synaptics"  "AlwaysCore"'
+      SYNMOUSE='InputDevice    "Synaptics" # "AlwaysCore"'
       SYNMOUSEDETAIL="
 Section \"InputDevice\"
   Driver        \"synaptics\"
@@ -374,7 +390,8 @@ EndSection
    if grep -q 'Device:.*Serial' "$MOUSEINFO" ; then
      SERIAL='yes'
      SERMOUSE='InputDevice    "Serial Mouse"     "CorePointer"'
-     SERMOUSEDETAIL="Section \"InputDevice\"
+     SERMOUSEDETAIL="
+Section \"InputDevice\"
         Identifier  \"Serial Mouse\"
         Driver      \"mouse\"
         Option      \"Device\" \"/dev/ttyS0\"
@@ -394,7 +411,8 @@ EndSection
    if [ -n "$USE_PS2" ] ; then
       PS2='yes'
       PS2MOUSE='InputDevice    "PS/2 Mouse"    "CorePointer"'
-      PS2MOUSEDETAIL="Section \"InputDevice\"
+      PS2MOUSEDETAIL="
+Section \"InputDevice\"
         Identifier  \"PS/2 Mouse\"
         Driver      \"mouse\"
         Option      \"Device\" \"/dev/input/mice\"
@@ -410,7 +428,8 @@ EndSection
       PS2MOUSEDETAIL=''
      fi
 
-     EVDEV_MOUSE="# Section \"InputDevice\"
+     EVDEV_MOUSE="
+# Section \"InputDevice\"
 #         Identifier      \"Generic Mouse\"
 #         Driver          \"evdev\"
 #         Option          \"Device\"                \"/dev/input/mice\"
@@ -570,6 +589,7 @@ EndSection"
      writehwinfo
 
      # monitor stuff
+     [ -r "$HWINFO_TMP" ] || bailout 1
      MONITOR=$(awk '/monitor.1:/{print $3}' $HWINFO_TMP)
      [[ $MONITOR != 'ddc' ]] && NODDC=yes
 
@@ -630,7 +650,7 @@ requirements()
 {
 if ! [ -x $(which hwinfo) ] ; then
   print "$bg[black]$fg[red]${bold_color}Error: hwinfo not found in path.${reset_color}
-Note:  run 'apt-get install hwinfo' on systems running debian.
+Note:  run 'aptitude install hwinfo' on systems running debian.
 Exiting.${reset_color}"
   exit -1
 fi
@@ -660,10 +680,14 @@ cat << EOX
 #   /usr/share/doc/xserver-xorg/   and
 #   http://wiki.x.org/wiki/Home    and
 #   http://ftp.x.org/pub/X11R7.0/doc/html/index.html for information on Xorg
+#
 # Refer to the xorg.conf man page and to
 # http://ftp.x.org/pub/X11R7.0/doc/html/xorg.conf.5.html
 # for details about the format of this file.
 #
+# See http://wiki.debian.org/XStrikeForce/FAQ for information
+# regarding Xorg packages within Debian.
+#
 # If you would like this file to be automatically reconfigured by debian,
 # run the following command:
 #   sudo dpkg-reconfigure -phigh xserver-xorg
@@ -674,13 +698,14 @@ Section "ServerLayout"
         Screen      0  "Screen0" 0 0
         # InputDevice    "Keyboard0"     "CoreKeyboard"
         # InputDevice    "Generic Mouse" "CorePointer"
+        Option "AutoAddDevices" "off" # do not depend on running dbus/hal
 $MOUSE
 EndSection
 
 Section "ServerFlags"
         Option "AllowMouseOpenFail"  "true"  # allows the server to start up even if the mouse does not work
         Option "DontVTSwitch"        "false" # allow switching between virtual terminal
-        # Option "DontZap"             "true"  # disable <Crtl><Alt><BS> (server abort)
+        Option "DontZap"             "false" # enable <Crtl><Alt><BS> (server abort)
         # Option "DontZoom"            "true"  # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
 EndSection
 
@@ -694,20 +719,21 @@ $XFONTS
         FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
 EndSection
 
-# Modules - see /usr/X11R6/lib/modules/fonts and /usr/X11R6/lib/modules/extensions
+# Modules - see /usr/lib/xorg/modules/fonts and /usr/lib/xorg/modules/extensions
 Section "Module"
         Load  "dbe"       # double buffer extension
         Load  "dri"       # direct rendering
         Load  "glx"       # 3D layer / GLX extension
-        Load  "type1"     # type1 font module
-        Load  "freetype"  # freetype fonts rendering
         Load  "extmod"    # some commonly used server extensions (e.g. shape extension)
         Load  "record"    # recording extension
         Load  "evdev"     # generic input handling driver on Linux
-        # Load  "vbe"       # Vesa BIOS Extension
+        Load  "xtrap"     # X Trap extension
+        # Load  "freetype"  # freetype fonts rendering
         # Load  "i2c"       # I2C bus
         # Load  "int10"     # initialize graphics cards via int10 call to the BIOS
+        # Load  "type1"     # type1 font module
         # Load  "v4l"       # Video for Linux
+        # Load  "vbe"       # Vesa BIOS Extension
         ## Deprecated/unneeded modules with Xorg >=7.0:
         # Load  "speedo"    # font module (does not exist anymore)
         # Load  "ddc"       # ddc probing of monitor (automatically loaded)
@@ -733,11 +759,7 @@ EndSection
 # EndSection
 
 # More information: http://ftp.x.org/pub/X11R7.0/doc/html/mouse.html
-$USBMOUSEDETAIL
-$PS2MOUSEDETAIL
-$SERMOUSEDETAIL
-$SYNMOUSEDETAIL
-$EVDEV_MOUSE
+${USBMOUSEDETAIL}${PS2MOUSEDETAIL}${SERMOUSEDETAIL}${SYNMOUSEDETAIL}${EVDEV_MOUSE}
 Section "Monitor"
         Identifier   "Monitor0"
 #       ModelName    "Old Monitor (no DDC)"
@@ -830,7 +852,7 @@ EOX
 
 # writeit {{{
 writeit() {
-    XCONFTMP="/tmp/xconfig.$$"
+    XCONFTMP="$(mktemp)"
     xconfig > $XCONFTMP
     # we do not want to have two CorePointers, deactivate one therefore
     if grep -Eq '^[[:space:]]+InputDevice[ ]+"USB Mouse"[ ]+"CorePointer"' $XCONFTMP ; then
@@ -870,6 +892,11 @@ $fg[red]"
 function runit
 {
   writeconfig
+  if [ "$(readlink /etc/X11/X)" = /bin/true ] ; then
+     print "$bold_color$fg[red]Fatal: /etc/X11/X is a symlink to /bin/true."
+     print "Fix it via running 'ln -sf /usr/bin/Xorg /etc/X11/X'"
+     exit 10
+  fi
   if [ -z "$NOSTART" ] ; then
     print "$reset_color"
     if [ -x /etc/init.d/xorg-common ] ; then
@@ -883,14 +910,15 @@ function runit
     if [ -z "$DISPLAY" ] ; then
       print "$bold_color$fg[green]Now trying to run startx.$reset_color"
       startx $XINITRC -- $XOPTS
+      return 1
     else
       print "$bold_color$fg[green]Now trying to run startx on display $DISPLAY.$reset_color"
       startx $XINITRC -- :$DISPLAY $XOPTS
+      return 1
     fi
   else
     print "$bold_color$fg[blue]Not running startx as requested via option.$reset_color"
   fi
-  return 1
 }
 # }}}
 
@@ -912,8 +940,8 @@ Please exit screen and try to run $PROGRAMNAME again."
   get-edid | parse-edid
 
 Do you want to go the debian way of life? Run:
-  apt-get install x-window-system-core read-edid mdetect hwinfo xdebconfigurator
-  dpkg-reconfigure x-window-system-core (or xserver-xorg depending on your system)
+  aptitude install xorg read-edid mdetect hwinfo xdebconfigurator
+  dpkg-reconfigure -phigh xserver-xorg
 
 Problems with the module used for X? Try to load another one or
 fall back to module vesa:
@@ -968,7 +996,7 @@ cleanup
 
 # xinitrc {{{
   if ! [ -x "$(which $WINDOWMANAGER)" ] ; then
-     print "$bg[black]$fg[red]${bold_color}Fatal: windowmanager $fg[blue]$WINDOWMANAGER$fg[red] not executable, startx won' work.${reset_color}">&2
+     print "$bg[black]$fg[red]${bold_color}Fatal: windowmanager $fg[blue]$WINDOWMANAGER$fg[red] not executable, startx will not work.${reset_color}">&2
      bailout
   fi
   if [ -w "$XINITRC" ] ; then