]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Fix xrandr -q parsing when output contains "primary"
authortachylatus <helgesdk@gmail.com>
Thu, 4 Jul 2013 10:39:40 +0000 (12:39 +0200)
committertachylatus <helgesdk@gmail.com>
Thu, 4 Jul 2013 11:36:03 +0000 (13:36 +0200)
xRandR (in newer versions?) will output an extra columns for primary outputs.
Detect this column and modify the string split and column numbers accordingly.

autorandr

index c2c3384e06e25d7de2e938a253efe82aeb773308..e38fcad575b046efb8ca0b9f1d5643b3285aaa30 100755 (executable)
--- a/autorandr
+++ b/autorandr
@@ -121,15 +121,22 @@ current_cfg_xrandr() {
        $XRANDR -q | awk -v primary_setup="${PRIMARY_SETUP}" '
        # display is connected and has a mode
        /^[^ ]+ connected [^(]/ {
-               split($3, A, "+");
                print "output "$1;
+               if ($3 == "primary") {
+                       print $3
+                       split($4, A, "+")
+                       $4=$5
+               }
+               else {
+                       split($3, A, "+");
+                       if (A[1] A[2] "," A[3] == primary_setup)
+                               print "primary";
+               }
                print "mode "A[1];
                print "pos "A[2]"x"A[3];
                if ($4 !~ /^\(/) {
                        print "rotate "$4;
                }
-               if (A[1] A[2] "," A[3] == primary_setup)
-                       print "primary";
                next;
        }
        # disconnected or disabled displays