]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Merge remote-tracking branches 'tachylatus/master' and 'herm/master'
authorPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 29 Nov 2013 06:43:48 +0000 (07:43 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 29 Nov 2013 06:43:48 +0000 (07:43 +0100)
autorandr
bash_completion/autorandr

index c2c3384e06e25d7de2e938a253efe82aeb773308..08725363e1627a52bb2f2f7bcbb7162644c754c9 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
@@ -167,7 +174,28 @@ config_equal() {
 }
 
 load_cfg_xrandr() {
-       sed 's!^!--!' "$1" | xargs $XRANDR
+       # sed 1: Prefix arguments with "--"
+       # sed 2: Merge arguments into one line per output
+       # sed 3: Merge into two lines, all --off outputs in the first one
+       sed 's/^/--/' "$1" | sed -e '
+               :START
+               /\n--output/{P;D}
+               s/\n/ /
+               N;bSTART' | sed -e '
+                       ### First line
+                       / --off/{
+                               G
+                               # Merge if next line contains --off
+                               s/\n\([^\n]* --off\)/ \1/
+                               h
+                               $!d;b
+                       }
+                       ### Last line
+                       H;x
+                       # Merge if previous line contains --mode
+                       s/\(--mode [^\n]*\)\n/\1 /
+                       h
+                       $!d' | xargs -L 1 $XRANDR
 }
 
 load_cfg_disper() {
index b00999452fdb4d4cb1b73ebc1ece66793858cccd..151c59698807c5b7de8d2a7ebc43b5677d88ecb0 100644 (file)
@@ -10,7 +10,11 @@ _autorandr ()
 
        opts="-h -c -s -l -d"
        lopts="--help --change --save --load --default --force --fingerprint"
-       prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
+       if [ -d ~/.autorandr ]; then
+               prfls="`find ~/.autorandr/* -maxdepth 1 -type d -printf '%f\n'`"
+       else
+               prfls=""
+       fi
 
        case "${cur}" in
                --*)