Skip to content

Commit

Permalink
Correctly handle connected, but unused screens.
Browse files Browse the repository at this point in the history
bugs #13
  • Loading branch information
phillipberndt committed Jan 22, 2015
1 parent 8e23d69 commit 2181c8e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions autorandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ class XrandrOutput(object):
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
Expand Down Expand Up @@ -191,6 +193,9 @@ def from_xrandr_output(cls, xrandr_output):
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"])
Expand All @@ -201,6 +206,8 @@ def from_xrandr_output(cls, xrandr_output):
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"
Expand Down

0 comments on commit 2181c8e

Please sign in to comment.