X-Git-Url: https://git.ralfj.de/lilass.git/blobdiff_plain/347af27784cca6310f62ad7dc65a070405a75878..HEAD:/lilass diff --git a/lilass b/lilass index b9283eb..3512a5f 100755 --- a/lilass +++ b/lilass @@ -22,14 +22,6 @@ import gui, screen, util, database frontend = gui.getFrontend("cli") # the fallback, until we got a proper frontend. This is guaranteed to be available. cmdArgs = None -# for auto-config: common names of internal connectors -commonInternalConnectorPrefixes = ['LVDS', 'eDP'] -commonInternalConnectorSuffices = ['', '0', '1', '-0', '-1'] -def commonInternalConnectorNames(): - for prefix in commonInternalConnectorPrefixes: - for suffix in commonInternalConnectorSuffices: - yield prefix+suffix - # Load a section-less config file: maps parameter names to space-separated lists of strings (with shell quotation) def loadConfigFile(filename): import shlex @@ -74,23 +66,10 @@ def situationByConfig(config): raise Exception("You must specify exactly one internal connector.") internalConnectors = config['internalConnector'] else: - internalConnectors = commonInternalConnectorNames() + internalConnectors = screen.commonInternalConnectorNames() # run! return screen.ScreenSituation(internalConnectors, config.get('externalConnectors')) -class ShowLevels(Enum): - ONEXTERNAL = ("on-external") - ONNEW = ("on-new") - ONERROR = ("on-error") - def __init__(self, text): - # auto numbering - cls = self.__class__ - self._value_ = len(cls.__members__) + 1 - self.text = text - @classmethod - def getNames(cls): - return list(x.text for x in cls) - # if we run top-level if __name__ == "__main__": try: @@ -114,6 +93,9 @@ if __name__ == "__main__": parser.add_argument("-s", "--silent", dest="silent", action='store_true', help="Prefer to be silent: Opens a UI only if the external screen is not known *and* no default configuration (-r/-e/-i) is given.") + parser.add_argument("--no-db", + dest="use_db", action='store_false', + help="Do not use the database of known screens.") parser.add_argument("-v", "--verbose", dest="verbose", action='store_true', help="More verbose output on stderr.") @@ -148,8 +130,9 @@ if __name__ == "__main__": # There's an external screen connected that we may want to use. # Fetch info about this screen from the database. # NOTE: If it is too slow to open the DB twice (reading and saving), we can keep it open all the time - with database.Database(databaseFilePath) as db: - situation.fetchDBInfo(db) + if cmdArgs.use_db: + with database.Database(databaseFilePath) as db: + situation.fetchDBInfo(db) # what to we do? have_default_conf = bool(cmdArgs.external_only or cmdArgs.internal_only or cmdArgs.rel_position) no_ui = bool(have_default_conf or (situation.previousSetup and cmdArgs.silent)) @@ -157,8 +140,10 @@ if __name__ == "__main__": # ask the user what to do setup = frontend.setup(situation) if setup is None: sys.exit(1) # the user canceled - with database.Database(databaseFilePath) as db: - situation.putDBInfo(db, setup) + if cmdArgs.use_db: + # persists this to disk + with database.Database(databaseFilePath) as db: + situation.putDBInfo(db, setup) elif situation.previousSetup: # apply the old setup again setup = situation.previousSetup @@ -167,9 +152,9 @@ if __name__ == "__main__": setup = screen.ScreenSetup(intResolution = None, extResolution = situation.externalConnector.getPreferredResolution()) elif cmdArgs.rel_position is not None: # construct automatically, based on CLI arguments - # first, figure out the desired RelativeScreenPosition... waht a bad hack... + # first, figure out the desired RelativeScreenPosition... what a bad hack... relPos = list(filter(lambda relPosItem: relPosFilter(relPosItem[0]) == cmdArgs.rel_position, screen.RelativeScreenPosition.__members__.items())) - assert len(relPos) == 1, "CLI argument is ambigue" + assert len(relPos) == 1, "CLI argument is ambiguous" relPos = relPos[0][1] # now we construct the ScreenSetup if relPos == screen.RelativeScreenPosition.MIRROR: