X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=autorandr.py;h=e19e8648f36597b39a175cae56917a4ae065b5b7;hb=3ba27e2dd51be30e99486960879d4fdbcfe2c2d4;hp=f70fc91a51dae1b74a271f6921320a96eda1c7c2;hpb=1d41e39939b126e1ce5e10ec1f307aa589f37983;p=deb_pkgs%2Fautorandr.git diff --git a/autorandr.py b/autorandr.py index f70fc91..e19e864 100755 --- a/autorandr.py +++ b/autorandr.py @@ -81,15 +81,15 @@ class XrandrOutput(object): \+(?P[0-9]+)\+(?P[0-9]+)\s+ # Position (?P[^(]\S+)? # Has a value if the output is rotated ).* - (?:\s+(?: # Properties of the output + (?:\s*(?: # Properties of the output Gamma: (?P[0-9\.:\s]+) | # Gamma value Transform: (?P[0-9\.\s]+) | # Transformation matrix EDID: (?P[0-9a-f\s]+) | # EDID of the output - (?![0-9])[^:\s]+:.*(?:\s\\t[\\t ].+)* # Other properties + (?![0-9])[^:\s][^:\n]+:.*(?:\s\\t[\\t ].+)* # Other properties ))+ \s* (?: [0-9]+x[0-9]+.+?\*current.+\s+h:.+\s+v:.+clock\s+(?P[0-9\.]+)Hz\s* | # Interesting (current) resolution: Extract rate - [0-9]+x[0-9]+.+\s+h:.+\s+v:.+\s* | # Other resolutions + [0-9]+x[0-9]+.+\s+h:.+\s+v:.+\s* # Other resolutions )* $ """ @@ -127,7 +127,11 @@ class XrandrOutput(object): @classmethod def from_xrandr_output(cls, xrandr_output): "Instanciate an XrandrOutput from the output of `xrandr --verbose'" - match = re.search(XrandrOutput.XRANDR_OUTPUT_REGEXP, xrandr_output).groupdict() + match_object = re.search(XrandrOutput.XRANDR_OUTPUT_REGEXP, xrandr_output) + remainder = xrandr_output[len(match_object.group(0)):] + if remainder: + raise RuntimeError("Parsing XRandR output failed, %d bytes left." % len(remainder)) + match = match_object.groupdict() options = {} if not match["connected"]: