]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blobdiff - autorandr.py
Updated README with missing contributors
[deb_pkgs/autorandr.git] / autorandr.py
index 2baa1b142ff3696f1215a6379fcb1c155a2a8664..da5217bf5658f61d0855f97bffb40cdfd23551bd 100755 (executable)
@@ -126,6 +126,8 @@ class XrandrOutput(object):
 
     XRANDR_DEFAULTS = dict(list(XRANDR_13_DEFAULTS.items()) + list(XRANDR_12_DEFAULTS.items()))
 
+    EDID_UNAVAILABLE = "--CONNECTED-BUT-EDID-UNAVAILABLE-"
+
     def __repr__(self):
         return "<%s%s %s>" % (self.output, (" %s..%s" % (self.edid[:5], self.edid[-5:])) if self.edid else "", " ".join(self.option_vector))
 
@@ -212,7 +214,7 @@ class XrandrOutput(object):
             edid = None
         elif not match["width"]:
             options["off"] = None
-            edid = "".join(match["edid"].strip().split())
+            edid = "".join(match["edid"].strip().split()) if match["edid"] else "%s-%s" % (XrandrOutput.EDID_UNAVAILABLE, match["output"])
         else:
             if match["mode_width"]:
                 options["mode"] = "%sx%s" % (match["mode_width"], match["mode_height"])
@@ -244,7 +246,7 @@ class XrandrOutput(object):
                 options["gamma"] = gamma
             if match["rate"]:
                 options["rate"] = match["rate"]
-            edid = "".join(match["edid"].strip().split())
+            edid = "".join(match["edid"].strip().split()) if match["edid"] else "%s-%s" % (XrandrOutput.EDID_UNAVAILABLE, match["output"])
 
         return XrandrOutput(match["output"], edid, options), modes
 
@@ -278,9 +280,9 @@ class XrandrOutput(object):
     def edid_equals(self, other):
         "Compare to another XrandrOutput's edid and on/off-state, taking legacy autorandr behaviour (md5sum'ing) into account"
         if self.edid and other.edid:
-            if len(self.edid) == 32 and len(other.edid) != 32:
+            if len(self.edid) == 32 and len(other.edid) != 32 and not other.edid.startswith(XrandrOutput.EDID_UNAVAILABLE):
                 return hashlib.md5(binascii.unhexlify(other.edid)).hexdigest() == self.edid
-            if len(self.edid) != 32 and len(other.edid) == 32:
+            if len(self.edid) != 32 and len(other.edid) == 32 and not self.edid.startswith(XrandrOutput.EDID_UNAVAILABLE):
                 return hashlib.md5(binascii.unhexlify(self.edid)).hexdigest() == other.edid
         return self.edid == other.edid
 
@@ -390,7 +392,7 @@ def find_profiles(current_config, profiles):
 
 def profile_blocked(profile_path):
     "Check if a profile is blocked"
-    script = os.path.join(profile_path, "blocked")
+    script = os.path.join(profile_path, "block")
     if not os.access(script, os.X_OK | os.F_OK):
         return False
     return subprocess.call(script) == 0
@@ -466,7 +468,7 @@ def apply_configuration(configuration, dry_run=False):
     # disable the last two screens. This is a problem, so if this would happen, instead disable only
     # one screen in the first call below.
     if len(disable_outputs) > 0 and len(disable_outputs) % 2 == 0:
-        # In the context of a xrandr call that changes the display change, `--query' should do nothing
+        # In the context of a xrandr call that changes the display state, `--query' should do nothing
         disable_outputs.insert(0, ['--query'])
 
     # Enable the remaining outputs in pairs of two operations