summaryrefslogtreecommitdiff
diff options
authorPMR <pmr@pmr-lander>2020-02-28 15:01:30 +0000
committerPMR <pmr@pmr-lander>2020-02-28 15:01:30 +0000
commit9ab468f2ed7d165f51536204f4ee1dd1a7ad3c07 (patch)
tree7bca275296941ed7bc3ba62d3d84f9dabff1549e
parent0c06eadd115b2cf015b8edcb756fe9236c151753 (diff)
parent615a6081184afd0d43dd8fa14ac9dd5e5ecad431 (diff)
Merge #379963 from ~kissiel/plainbox-provider-checkbox:xrandr-final-showdown
-rwxr-xr-xbin/xrandr_cycle17
1 files changed, 13 insertions, 4 deletions
diff --git a/bin/xrandr_cycle b/bin/xrandr_cycle
index 34f953c..6743f6f 100755
--- a/bin/xrandr_cycle
+++ b/bin/xrandr_cycle
@@ -33,7 +33,8 @@ failure_messages = [] # remember which modes failed
success_messages = [] # remember which modes succeeded
# Run xrandr and ask it what devices and modes are supported
-xrandrinfo = subprocess.Popen('xrandr -q', shell=True, stdout=subprocess.PIPE)
+xrandrinfo = subprocess.Popen(
+ 'xrandr -q --verbose', shell=True, stdout=subprocess.PIPE)
output = xrandrinfo.communicate()[0].decode().split('\n')
@@ -62,12 +63,20 @@ for line in output:
elif device_context != '': # we've previously seen a 'connected' dev
# mode names seem to always be of the format [horiz]x[vert]
# (there can be non-mode information inside of a device context!)
- if foo[0].find('x') != -1:
- modes.append((device_context, foo[0]))
+ x_pos = foo[0].find('x')
+ # for a resolution there has to be at least 3 chars:
+ # a digit, an x, and a digit
+ if x_pos > 0 and x_pos < len(foo[0]) - 1:
+ if 'DoubleScan' in foo:
+ # xrandr lists DoubleScan resolutions but cannot set them
+ # so for the purposes of this test let's not use them
+ continue
+ if foo[0][x_pos-1].isdigit() and foo[0][x_pos+1].isdigit():
+ modes.append((device_context, foo[0]))
# we also want to remember what the current mode is, which xrandr
# marks with a '*' character, so we can set things back the way
# we found them at the end:
- if foo[1].find('*') != -1:
+ if "*current" in foo:
current_modes.append((device_context, foo[0]))
# let's create a dict of aspect_ratio:largest_width for each display
# (width, because it's easier to compare simple ints when looking for the