projects
/
lilass.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
662aa4a
)
add support for several external connectors (of which only one is used)
author
Ralf Jung
<post@ralfj.de>
Mon, 20 Aug 2012 15:52:42 +0000
(17:52 +0200)
committer
Ralf Jung
<post@ralfj.de>
Mon, 20 Aug 2012 15:52:42 +0000
(17:52 +0200)
external_screen.py
patch
|
blob
|
history
selector_window.py
patch
|
blob
|
history
diff --git
a/external_screen.py
b/external_screen.py
index 01c744ba2fe350c2810bdb457524674b951f13fd..5474685d1f06ad7b26b646c2e42f1ee3b52120d3 100755
(executable)
--- a/
external_screen.py
+++ b/
external_screen.py
@@
-42,39
+42,50
@@
def res2user(res):
return '%dx%d (%s)' %(w, h, strRatio)
# Check screen setup
return '%dx%d (%s)' %(w, h, strRatio)
# Check screen setup
-internalName = "LVDS"
-externalName
= "CRT1"
+internalName = "LVDS
1
"
+externalName
s = ["HDMI1", "VGA1"]
connectors = getXrandrInformation()
internalResolutions = connectors[internalName] # there must be a screen assoicated to the internal connector
connectors = getXrandrInformation()
internalResolutions = connectors[internalName] # there must be a screen assoicated to the internal connector
-externalResolutions = connectors.get(externalName)
+externalName = None # *the* external connector which is actually used
+externalResolutions = None # resultions of the external connector
+args = {} # maps connector names to xrand arguments
+
+# look for enabled external screen, disable all the others
+for name in externalNames:
+ if externalResolutions is None and name in connectors:
+ externalName = name
+ externalResolutions = connectors[name]
+ else:
+ args[name] = ["--off"]
# Check what to do
# Check what to do
-if external
Resolutions
is not None: # we need to ask what to do
- extPosition = PositionSelection(map(res2user, internalResolutions), map(res2user, externalResolutions))
+if external
Name
is not None: # we need to ask what to do
+ extPosition = PositionSelection(
externalName,
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
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
-
externalArgs
= ["--mode", extResolution] # we definitely want an external screen
+
args[externalName]
= ["--mode", extResolution] # we definitely want an external screen
if extPosition.extOnly.isChecked():
if extPosition.extOnly.isChecked():
-
internalArgs
= ["--off"]
-
externalArgs
+= ["--primary"]
+
args[internalName]
= ["--off"]
+
args[externalName]
+= ["--primary"]
else:
# there are two screens
else:
# there are two screens
-
internalArgs
= ["--mode", intResolution]
+
args[internalName]
= ["--mode", intResolution]
if extPosition.posLeft.isChecked():
if extPosition.posLeft.isChecked():
-
externalArgs
+= ["--left-of", internalName]
+
args[externalName]
+= ["--left-of", internalName]
else:
else:
-
externalArgs
+= ["--right-of", internalName]
+
args[externalName]
+= ["--right-of", internalName]
if extPosition.primExt.isChecked():
if extPosition.primExt.isChecked():
-
externalArgs
+= ["--primary"]
+
args[externalName]
+= ["--primary"]
else:
else:
-
internalArgs
+= ["--primary"]
+
args[internalName]
+= ["--primary"]
else:
else:
- internalArgs = ["--mode", res2xrandr(internalResolutions[0]), "--primary"]
- externalArgs = ["--off"]
+ args[internalName] = ["--mode", res2xrandr(internalResolutions[0]), "--primary"]
# and do it
# and do it
-call = ["xrandr", "--output", internalName] + internalArgs + ["--output", externalName] + externalArgs
+call = ["xrandr"]
+for name in args:
+ call += ["--output", name] + args[name]
print "Call that will be made:",call
subprocess.check_call(call)
print "Call that will be made:",call
subprocess.check_call(call)
diff --git
a/selector_window.py
b/selector_window.py
index adee7e42c7d70d1771060e674a952e4b3e9e1cc4..7df0a4483d65476485eabdc94dfc7a400e0ff47d 100644
(file)
--- a/
selector_window.py
+++ b/
selector_window.py
@@
-14,10
+14,10
@@
class PositionSelection(QtGui.QDialog):
RIGHT = 20
EXTERNAL_ONLY = 30
RIGHT = 20
EXTERNAL_ONLY = 30
- def __init__(self, internalResolutions, externalResolutions):
+ def __init__(self,
externalName,
internalResolutions, externalResolutions):
# set up main window
super(PositionSelection, self).__init__()
# set up main window
super(PositionSelection, self).__init__()
- self.setWindowTitle('External screen setup
'
)
+ self.setWindowTitle('External screen setup
(connector: %s)' % externalName
)
# position selection
posBox = QtGui.QGroupBox('Position of external screen', self)
# position selection
posBox = QtGui.QGroupBox('Position of external screen', self)