- if not cmdArgs.internal_only and situation.externalResolutions() is not None:
- # there's an external screen connected that we may want to use
- if cmdArgs.external_only:
- setup = screen.ScreenSetup(intResolution = None, extResolution = situation.externalResolutions()[0])
+ if situation.externalConnector is not None:
+ # 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)
+ # 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))
+ if not no_ui:
+ # 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)
+ elif situation.previousSetup:
+ # apply the old setup again
+ setup = situation.previousSetup
+ # use default config from CLI
+ elif cmdArgs.external_only:
+ setup = screen.ScreenSetup(intResolution = None, extResolution = situation.externalConnector.getPreferredResolution())