X-Git-Url: https://git.ralfj.de/lilass.git/blobdiff_plain/347af27784cca6310f62ad7dc65a070405a75878..7f7312acf4942364d6a5bb0b63e7f7a823c11d9b:/screen.py diff --git a/screen.py b/screen.py index a95d45d..133e333 100644 --- a/screen.py +++ b/screen.py @@ -87,7 +87,9 @@ class Resolution: def __str__(self): # get ratio ratio = int(round(16.0*self.height/self.width)) - if ratio == 12: # 16:12 = 4:3 + if ratio == 11: # 16:10.66 = 3:2 + strRatio = "3:2" + elif ratio == 12: # 16:12 = 4:3 strRatio = '4:3' elif ratio == 13: # 16:12.8 = 5:4 strRatio = '5:4' @@ -196,11 +198,11 @@ class ScreenSituation: previousSetup = None # None or the ScreenSetup used the last time this external screen was connected '''Represents the "screen situation" a machine can be in: Which connectors exist, which resolutions do they have, what are the names for the internal and external screen''' - def __init__(self, internalConnectorNames, externalConnectorNames = None): + def __init__(self, internalConnectorNames, externalConnectorNames = None, xrandrSource = None): '''Both arguments are lists of connector names. The first one which exists and has a screen attached is chosen for that class. can be None to just choose any remaining connector.''' # which connectors are there? - self._getXrandrInformation() + self._getXrandrInformation(xrandrSource) # figure out which is the internal connector self.internalConnector = self._findAvailableConnector(internalConnectorNames) if self.internalConnector is None: @@ -216,9 +218,11 @@ class ScreenSituation: print("Detected external connector:",self.externalConnector) # Run xrandr and fill the dict of connector names mapped to lists of available resolutions. - def _getXrandrInformation(self): + def _getXrandrInformation(self, xrandrSource = None): connector = None # current connector readingEdid = False + if xrandrSource is None: + xrandrSource = processOutputGen("xrandr", "-q", "--verbose") for line in processOutputGen("xrandr", "-q", "--verbose"): if readingEdid: m = re.match(r'^\s*([0-9a-f]+)\s*$', line)