From: Phillip Berndt Date: Thu, 22 Jan 2015 13:27:29 +0000 (+0100) Subject: Correctly handle connected, but unused screens. X-Git-Tag: 1.0~98 X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fautorandr.git;a=commitdiff_plain;h=2181c8ef025f4e0997a4393832b3d686f5990d3d Correctly handle connected, but unused screens. bugs #13 --- diff --git a/autorandr.py b/autorandr.py index 18381df..b2bca69 100755 --- a/autorandr.py +++ b/autorandr.py @@ -83,12 +83,14 @@ class XrandrOutput(object): disconnected | unknown\ connection | (?Pconnected)\s+ # If connected: + (?: (?Pprimary\ )? # Might be primary screen (?P[0-9]+)x(?P[0-9]+) # Resolution (might be overridden below!) \+(?P[0-9]+)\+(?P[0-9]+)\s+ # Position (?:\(0x[0-9a-fA-F]+\)\s+)? # XID (?P(?:normal|left|right|inverted))\s+ # Rotation (?:(?PX\ 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[0-9\.:\s]+) | # Gamma value @@ -191,6 +193,9 @@ class XrandrOutput(object): 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"]) @@ -201,6 +206,8 @@ class XrandrOutput(object): 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"