disconnected |
unknown\ connection |
(?P<connected>connected)\s+ # If connected:
+ (?:
(?P<primary>primary\ )? # Might be primary screen
(?P<width>[0-9]+)x(?P<height>[0-9]+) # Resolution (might be overridden below!)
\+(?P<x>[0-9]+)\+(?P<y>[0-9]+)\s+ # Position
(?:\(0x[0-9a-fA-F]+\)\s+)? # XID
(?P<rotate>(?:normal|left|right|inverted))\s+ # Rotation
(?:(?P<reflect>X\ 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<gamma>[0-9\.:\s]+) | # Gamma value
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"])
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"
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"]
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 "
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