Some further error handling regarding Xinerama
authorMichael Prokop <mika@grml.org>
Fri, 27 Jul 2007 23:22:13 +0000 (01:22 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 27 Jul 2007 23:22:13 +0000 (01:22 +0200)
debian/changelog
grml-x

index 45a2224..c92a309 100644 (file)
@@ -1,3 +1,11 @@
+grml-x (0.3.30) unstable; urgency=low
+
+  * Some further error handling regarding Xinerama.
+    We still don't have a reliable way to find the maximum resolution
+    of an external monitor, needs some further investigation.
+
+ -- Michael Prokop <mika@grml.org>  Sat, 28 Jul 2007 01:20:54 +0200
+
 grml-x (0.3.29) unstable; urgency=low
 
   * Mention http://wiki.debian.org/XStrikeForce/FAQ in the xorg.conf
diff --git a/grml-x b/grml-x
index 32a3ed9..97e2ae1 100755 (executable)
--- a/grml-x
+++ b/grml-x
@@ -220,12 +220,20 @@ Just press Ctrl-C to cancel operation.
          # 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"