Skip to content

Commit 376005b

Browse files
committed
Fix parsing of EDID
See bug wertarbyte#19.
1 parent 527c3cd commit 376005b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

autorandr.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ class XrandrOutput(object):
9494
)? # .. but everything of the above only if the screen is in use.
9595
).*
9696
(?:\s*(?: # Properties of the output
97-
Gamma: (?P<gamma>[0-9\.:\s]+) | # Gamma value
98-
Transform: (?P<transform>[\-0-9\.\s]+) | # Transformation matrix
99-
EDID: (?P<edid>[0-9a-f\s]+) | # EDID of the output
97+
Gamma: (?P<gamma>[0-9\.: ]+) | # Gamma value
98+
Transform: (?P<transform>(?:[\-0-9\.]+\s+){3}) | # Transformation matrix
99+
EDID: (?P<edid>\s*?(?:\\n\\t\\t[0-9a-f]+)+) | # EDID of the output
100100
(?![0-9])[^:\s][^:\n]+:.*(?:\s\\t[\\t ].+)* # Other properties
101101
))+
102102
\s*
@@ -186,6 +186,7 @@ def from_xrandr_output(cls, xrandr_output):
186186
This method also returns a list of modes supported by the output.
187187
"""
188188
try:
189+
xrandr_output = xrandr_output.replace("\r\n", "\n")
189190
match_object = re.search(XrandrOutput.XRANDR_OUTPUT_REGEXP, xrandr_output)
190191
except:
191192
raise RuntimeError("Parsing XRandR output failed, there is an error in the regular expression.")
@@ -194,9 +195,8 @@ def from_xrandr_output(cls, xrandr_output):
194195
raise RuntimeError("Parsing XRandR output failed, the regular expression did not match: %s" % debug)
195196
remainder = xrandr_output[len(match_object.group(0)):]
196197
if remainder:
197-
raise RuntimeError(("Parsing XRandR output failed, %d bytes left unmatched after regular expression,"
198-
"starting with ..'%s'.") % (len(remainder), remainder[:10]))
199-
198+
raise RuntimeError(("Parsing XRandR output failed, %d bytes left unmatched after regular expression, "
199+
"starting at byte %d with ..'%s'.") % (len(remainder), len(len(match_object.group(0))), remainder[:10]))
200200

201201
match = match_object.groupdict()
202202

0 commit comments

Comments
 (0)