- # 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]
+ extPosition = PositionSelection(usedExternalConnector, map(res2user, internalResolutions), map(res2user, externalResolutions))
+ extPosition.exec_()
+ if not extPosition.result(): sys.exit(1) # the user canceled
+ extResolution = res2xrandr(externalResolutions[extPosition.extResolutions.currentIndex()])
+ intResolution = res2xrandr(internalResolutions[extPosition.intResolutions.currentIndex()])
+ # build command-line
+ args[usedExternalConnector] = ["--mode", extResolution] # set external screen to desired resolution
+ if extPosition.extOnly.isChecked():
+ args[usedExternalConnector] += ["--primary"]