X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=autorandr.py;h=1be7e7bbd31763397e3507217d15a285db4a7f8d;hb=36372f535ddea5b3276c340f804115ca9c905175;hp=c7aa86623b29503d9e60aad794543a159d5792c8;hpb=cf2b326a2498bee2f6af3fc190d673cd6831b93c;p=deb_pkgs%2Fautorandr.git diff --git a/autorandr.py b/autorandr.py index c7aa866..1be7e7b 100755 --- a/autorandr.py +++ b/autorandr.py @@ -83,12 +83,14 @@ class XrandrOutput(object): disconnected | unknown\ connection | (?Pconnected)\s+ # If connected: + (?: (?Pprimary\ )? # Might be primary screen (?P[0-9]+)x(?P[0-9]+) # Resolution (might be overridden below!) \+(?P[0-9]+)\+(?P[0-9]+)\s+ # Position (?:\(0x[0-9a-fA-F]+\)\s+)? # XID (?P(?:normal|left|right|inverted))\s+ # Rotation (?:(?PX\ and\ Y|X|Y)\ axis)? # Reflection + )? # .. but everything of the above only if the screen is in use. ).* (?:\s*(?: # Properties of the output Gamma: (?P[0-9\.:\s]+) | # Gamma value @@ -191,6 +193,9 @@ class XrandrOutput(object): if not match["connected"]: options["off"] = None edid = None + elif not match["width"]: + options["off"] = None + edid = "".join(match["edid"].strip().split()) else: if "mode_width" in match: options["mode"] = "%sx%s" % (match["mode_width"], match["mode_height"]) @@ -201,6 +206,8 @@ class XrandrOutput(object): options["mode"] = "%sx%s" % (match["height"], match["width"]) if match["rotate"] != "normal": options["rotate"] = match["rotate"] + if "primary" in match and match["primary"]: + options["primary"] = None if "reflect" in match: if match["reflect"] == "X": options["reflect"] = "x" @@ -235,17 +242,17 @@ class XrandrOutput(object): if line: line = line.split(None, 1) options[line[0]] = line[1] if len(line) > 1 else None - if "off" in options: + + if options["output"] in edid_map: + edid = edid_map[options["output"]] + elif "off" in options: edid = None else: - if options["output"] in edid_map: - edid = edid_map[options["output"]] - else: - fuzzy_edid_map = [ re.sub("(card[0-9]+|-)", "", x) for x in edid_map.keys() ] - fuzzy_output = re.sub("(card[0-9]+|-)", "", options["output"]) - if fuzzy_output not in fuzzy_edid_map: - raise RuntimeError("Failed to find a corresponding output in config/setup for output `%s'" % options["output"]) - edid = edid_map[list(edid_map.keys())[fuzzy_edid_map.index(fuzzy_output)]] + fuzzy_edid_map = [ re.sub("(card[0-9]+|-)", "", x) for x in edid_map.keys() ] + fuzzy_output = re.sub("(card[0-9]+|-)", "", options["output"]) + if fuzzy_output not in fuzzy_edid_map: + raise RuntimeError("Failed to find a corresponding output in config/setup for output `%s'" % options["output"]) + edid = edid_map[list(edid_map.keys())[fuzzy_edid_map.index(fuzzy_output)]] output = options["output"] del options["output"] @@ -278,6 +285,8 @@ def debug_regexp(pattern, string): bounds = ( 0, len(string) ) while bounds[0] != bounds[1]: half = int((bounds[0] + bounds[1]) / 2) + if half == bounds[0]: + break bounds = (half, bounds[1]) if regex.search(pattern, string[:half], partial=True) else (bounds[0], half - 1) partial_length = bounds[0] return ("Regular expression matched until position " @@ -331,7 +340,7 @@ def load_profiles(profile_path): buffer.append(line) for output_name in list(config.keys()): - if "off" in config[output_name].options: + if config[output_name].edid is None: del config[output_name] profiles[profile] = config