From e4d485b1b32ac7044b1cc78790fbaad5e0e1bdff Mon Sep 17 00:00:00 2001 From: Phillip Berndt Date: Fri, 2 Jan 2015 09:23:20 +0100 Subject: [PATCH] Reimplemented the setup_fp methods 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 | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/autorandr b/autorandr index fa575b1..7152ca0 100755 --- 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() { -- 2.39.5