]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Reimplemented the setup_fp methods
authorPhillip Berndt <phillip.berndt@googlemail.com>
Fri, 2 Jan 2015 08:23:20 +0000 (09:23 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Wed, 7 Jan 2015 06:39:25 +0000 (07:39 +0100)
In order to resolve bug #7, we need to remove non-trivial pieces of code
by @wertarbyte, who does not react to requests currently. All other
authors agreed to any suitable OSS license. See
 https://github.com/phillipberndt/autorandr/issues/7
for further discussion.

A side-effect of my reimplementation is that both methods now return the
same fingerprint, such that they are interchangeable. A downside is that
the fingerprints change with this version.

autorandr

index fa575b196346552dd44c10666468ce428caef9b8..7152ca0ecf11fa8d5d63b0bafd2bf14e0ff4efa7 100755 (executable)
--- a/autorandr
+++ b/autorandr
@@ -80,22 +80,30 @@ fi
 
 setup_fp_xrandr_edid() {
        $XRANDR -q --verbose | awk '
-       /^[^ ]+ (dis)?connected / { DEV=$1; }
-       $1 ~ /^[a-f0-9]+$/ { ID[DEV] = ID[DEV] $1 }
-       END { for (X in ID) { print X " " ID[X]; } }'
+       ORS="";
+       / (dis)?connected/ { DEVICE=gensub("-([A-Z]-)?", "", "g", $1) " "; }
+       /^[[:blank:]]+EDID:/ {
+               print DEVICE
+               DEVICE=""
+               for(getline; /^[[:blank:]]+[0-9a-f]+$/; getline) {
+                       print $1;
+               }
+               print "\n";
+       }
+       END {
+               print "\n";
+       }
+       '
 }
 
 setup_fp_sysfs_edid() {
-       # xrandr triggers the reloading of EDID data
+       which xxd >/dev/null 2>&1 || return
        $XRANDR -q > /dev/null
-       # hash the EDIDs of all _connected_ devices
-       for P in /sys/class/drm/card*-*/; do
-               # nothing found
-               [ ! -d "$P" ] && continue
-               if grep -q "^connected$" < "${P}status"; then
-                       echo -n "$(basename "$P") "
-                       md5sum ${P}edid | awk '{print $1}'
-               fi
+       for DEVICE in /sys/class/drm/card*-*; do
+               [ -e "${DEVICE}/status" ] && grep -q "^connected$" "${DEVICE}/status" || continue
+               echo -n "$(echo "${DEVICE}/edid" | sed -re 's#^.+card[0-9]+-([^/]+).+#\1#; s#-([A-Z]-)?##') "
+                       xxd -c 256 -ps "${DEVICE}/edid" | awk 'ORS=""; /.+/ { print; }'
+               echo
        done
 }
 
@@ -115,7 +123,7 @@ setup_fp() {
                echo "Unable to fingerprint display configuration" >&2
                return
        fi
-       echo "$FP"
+       echo "$FINGERPRINT" | sort
 }
 
 current_cfg_xrandr() {