else:
import configparser
-__version__ = "1.7"
+__version__ = "1.8.1"
try:
input = raw_input
# This regular expression is used to parse an output in `xrandr --verbose'
XRANDR_OUTPUT_REGEXP = """(?x)
- ^(?P<output>[^ ]+)\s+ # Line starts with output name
+ ^\s*(?P<output>\S[^ ]*)\s+ # Line starts with output name
(?: # Differentiate disconnected and connected
disconnected | # in first line
unknown\ connection |
(?:[\ \t]*border\ (?P<border>(?:[0-9]+/){3}[0-9]+))? # Border information
(?:\s*(?: # Properties of the output
Gamma: (?P<gamma>(?:inf|[0-9\.: e])+) | # Gamma value
+ CRTC:\s*(?P<crtc>[0-9]) | # CRTC value
Transform: (?P<transform>(?:[\-0-9\. ]+\s+){3}) | # Transformation matrix
EDID: (?P<edid>\s*?(?:\\n\\t\\t[0-9a-f]+)+) | # EDID of the output
(?![0-9])[^:\s][^:\n]+:.*(?:\s\\t[\\t ].+)* # Other properties
else:
edid = "%s-%s" % (XrandrOutput.EDID_UNAVAILABLE, match["output"])
- if not match["connected"]:
+ if not match["connected"] or not match["width"]:
options["off"] = None
else:
if match["mode_name"]:
options["reflect"] = "y"
elif match["reflect"] == "X and Y":
options["reflect"] = "xy"
- options["pos"] = "%sx%s" % (match["x"], match["y"])
+ if match["x"] or match["y"]:
+ options["pos"] = "%sx%s" % (match["x"] or "0", match["y"] or "0")
if match["panning"]:
panning = [match["panning"]]
if match["tracking"]:
# so we approximate by 1e-10.
gamma = ":".join([str(max(1e-10, round(1. / float(x), 3))) for x in gamma.split(":")])
options["gamma"] = gamma
+ if match["crtc"]:
+ options["crtc"] = match["crtc"]
if match["rate"]:
options["rate"] = match["rate"]
if "panning" in output.options:
match = re.match("(?P<w>[0-9]+)x(?P<h>[0-9]+)(?:\+(?P<x>[0-9]+))?(?:\+(?P<y>[0-9]+))?.*", output.options["panning"])
if match:
- detail = match.groupdict()
- o_width = int(detail.get("w")) + int(detail.get("x", "0"))
- o_height = int(detail.get("h")) + int(detail.get("y", "0"))
+ detail = match.groupdict(default="0")
+ o_width = int(detail.get("w")) + int(detail.get("x"))
+ o_height = int(detail.get("h")) + int(detail.get("y"))
width = max(width, o_width)
height = max(height, o_height)
return int(width), int(height)
if not new_configuration[output].edid or "off" in new_configuration[output].options:
disable_outputs.append(new_configuration[output].option_vector)
else:
+ if output not in current_configuration:
+ raise AutorandrException("New profile configures output %s which does not exist in current xrandr --verbose output. "
+ "Don't know how to proceed." % output)
if "off" not in current_configuration[output].options:
remain_active_count += 1