- # there are two screens
- args[internalName] = ["--mode", intResolution]
- if extPosition.posLeft.isChecked():
- args[externalName] += ["--left-of", internalName]
- else:
- args[externalName] += ["--right-of", internalName]
- if extPosition.primExt.isChecked():
- args[externalName] += ["--primary"]
+ externalConnectors = connectors.keys()
+ externalConnectors.remove(internalConnector)
+ if not externalConnectors:
+ raise Exception("No external connector found - either your config is wrong, or your machine has only one connector.")
+
+ # default: screen off
+ args = {} # maps connector names to xrand arguments
+ for c in externalConnectors+[internalConnector]:
+ args[c] = ["--off"]
+
+ # Check what to do
+ usedExternalConnector = findAvailableConnector(externalConnectors, connectors) # *the* external connector which is actually used
+ if usedExternalConnector is not None: # there's an external screen connected, we need to ask what to do
+ internalResolutions = connectors[internalConnector]
+ externalResolutions = connectors[usedExternalConnector]
+ dialogue = gui.getDialogue(usedExternalConnector, map(res2user, internalResolutions), map(res2user, externalResolutions))
+ if not dialogue.run(): sys.exit(1) # the user canceled
+ extResolution = res2xrandr(externalResolutions[dialogue.getExtResolutionIndex()])
+ intResolution = res2xrandr(internalResolutions[dialogue.getIntResolutionIndex()])
+ relPosition = dialogue.getRelativeScreenPosition()
+ # build command-line
+ args[usedExternalConnector] = ["--mode", extResolution] # set external screen to desired resolution
+ if relPosition == RelativeScreenPosition.EXTERNAL_ONLY:
+ args[usedExternalConnector] += ["--primary"]