X-Git-Url: https://git.ralfj.de/lilass.git/blobdiff_plain/4a96a6beedb82ccb2df60a1b358e5ff7741a0191..436dc315ae39dfac14edd1c208c26c7419e9f58e:/screen.py diff --git a/screen.py b/screen.py index 9942e98..b096fb1 100644 --- a/screen.py +++ b/screen.py @@ -129,6 +129,7 @@ class Connector: self.name = name # connector name, e.g. "HDMI1" self.edid = None # EDID string for the connector, or None if disconnected self.resolutions = set() # list of Resolution objects, empty if disconnected + self.preferredResolution = None def __str__(self): return str(self.name) @@ -149,6 +150,11 @@ class Connector: self.edid = s else: self.edid += s + + def getPreferredResolution(self): + if self.preferredResolution: + return self.preferredResolution + return max(self.resolutions, key=lambda r: r.pixelCount()) class ScreenSituation: connectors = [] # contains all the Connector objects @@ -209,6 +215,8 @@ class ScreenSituation: resolution = Resolution(int(m.group(1)), int(m.group(2))) assert connector is not None connector.addResolution(resolution) + if '+preferred' in line: + connector.preferredResolution = resolution continue # EDID? m = re.search(r'^\s*EDID:\s*$', line)