projects
/
lilass.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
93e1258
)
show aspect ratio of resolutions
author
Ralf Jung
<post@ralfj.de>
Fri, 20 Jul 2012 15:03:59 +0000
(17:03 +0200)
committer
Ralf Jung
<post@ralfj.de>
Fri, 20 Jul 2012 15:03:59 +0000
(17:03 +0200)
external_screen.py
patch
|
blob
|
history
diff --git
a/external_screen.py
b/external_screen.py
index 6d47ec725962fdc1a713a1b7f756fba9cb7ce07a..895405e20d4a2fd01217ce306f64b596809b1bc6 100755
(executable)
--- a/
external_screen.py
+++ b/
external_screen.py
@@
-25,10
+25,22
@@
def getXrandrInformation():
if p.returncode != 0: raise Exception("Querying xrandr for data failed")
return connectors
if p.returncode != 0: raise Exception("Querying xrandr for data failed")
return connectors
-def res2
st
r(res):
+def res2
xrand
r(res):
(w, h) = res
return str(w)+'x'+str(h)
(w, h) = res
return str(w)+'x'+str(h)
+def res2user(res):
+ (w, h) = res
+ # get ratio
+ ratio = int(round(16.0*h/w))
+ if ratio == 12: # 16:12 = 4:3
+ strRatio = '4:3'
+ elif ratio == 13: # 16:12.8 = 5:4
+ strRatio = '5:4'
+ else: # let's just hope this will never be 14 or more...
+ strRatio = '16:%d' % ratio
+ return '%dx%d (%s)' %(w, h, strRatio)
+
# Check screen setup
internalName = "LVDS"
externalName = "CRT1"
# Check screen setup
internalName = "LVDS"
externalName = "CRT1"
@@
-38,11
+50,11
@@
externalResolutions = connectors.get(externalName)
# Check what to do
if externalResolutions is not None: # we need to ask what to do
# Check what to do
if externalResolutions is not None: # we need to ask what to do
- extPosition = PositionSelection(map(res2
str, internalResolutions), map(res2st
r, externalResolutions))
+ extPosition = PositionSelection(map(res2
user, internalResolutions), map(res2use
r, externalResolutions))
extPosition.exec_()
if not extPosition.result(): sys.exit(1) # the user canceled
extPosition.exec_()
if not extPosition.result(): sys.exit(1) # the user canceled
- extResolution = res2
st
r(externalResolutions[extPosition.extResolutions.currentIndex()])
- intResolution = res2
st
r(internalResolutions[extPosition.intResolutions.currentIndex()])
+ extResolution = res2
xrand
r(externalResolutions[extPosition.extResolutions.currentIndex()])
+ intResolution = res2
xrand
r(internalResolutions[extPosition.intResolutions.currentIndex()])
# build command-line
externalArgs = ["--mode", extResolution] # we definitely want an external screen
if extPosition.extOnly.isChecked():
# build command-line
externalArgs = ["--mode", extResolution] # we definitely want an external screen
if extPosition.extOnly.isChecked():
@@
-60,7
+72,7
@@
if externalResolutions is not None: # we need to ask what to do
else:
internalArgs += ["--primary"]
else:
else:
internalArgs += ["--primary"]
else:
- internalArgs = ["--mode", res2str(internalResolutions[0]), "--primary"]
# there must be a resolution for the internal screen
+ internalArgs = ["--mode", res2str(internalResolutions[0]), "--primary"]
externalArgs = ["--off"]
# and do it
call = ["xrandr", "--output", internalName] + internalArgs + ["--output", externalName] + externalArgs
externalArgs = ["--off"]
# and do it
call = ["xrandr", "--output", internalName] + internalArgs + ["--output", externalName] + externalArgs