From: Rasmus Wriedt Larsen Date: Thu, 22 Jan 2015 20:50:05 +0000 (+0100) Subject: allow legacy autorandr to be off while connected X-Git-Tag: 1.0~95 X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fautorandr.git;a=commitdiff_plain;h=2b0a226d0d370c79901d77c0d70a9f72d9e45a41 allow legacy autorandr to be off while connected --- diff --git a/autorandr.py b/autorandr.py index 1be7e7b..01632ee 100755 --- a/autorandr.py +++ b/autorandr.py @@ -243,16 +243,19 @@ class XrandrOutput(object): line = line.split(None, 1) options[line[0]] = line[1] if len(line) > 1 else None + edid = None + if options["output"] in edid_map: edid = edid_map[options["output"]] - elif "off" in options: - edid = None else: + # This fuzzy matching is for legacy autorandr that used sysfs output names 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)]] + if fuzzy_output in fuzzy_edid_map: + edid = edid_map[list(edid_map.keys())[fuzzy_edid_map.index(fuzzy_output)]] + elif "off" not in options: + raise RuntimeError("Failed to find an EDID for output `%s' in setup file, required as `%s' is not off in config file." + % (options["output"], options["output"])) output = options["output"] del options["output"]