summaryrefslogtreecommitdiff
path: root/bin
diff options
authorMaciej Kisielewski <maciej.kisielewski@canonical.com>2020-02-27 13:48:29 +0100
committerMaciej Kisielewski <maciej.kisielewski@canonical.com>2020-02-27 13:48:29 +0100
commit615a6081184afd0d43dd8fa14ac9dd5e5ecad431 (patch)
tree7bca275296941ed7bc3ba62d3d84f9dabff1549e /bin
parent0c06eadd115b2cf015b8edcb756fe9236c151753 (diff)
xrand_cycle: don't try setting resolutions that don't work
The long-lasting problem was that xrandr listed resolution it could not set. The resolutions in question are ones that use DoubleScan (due to their _usual_ low pixel count each row is scanned twice so the refresh frequencies are not bonkers). This patch changes how xrandr_cycle polls for available modes from xrandr, so we can not take into consideration the DoubleScan modes. The modes that are not filtered out should be valid modes that xrandr can use. Fixes: LP: #1627581
Diffstat (limited to 'bin')
-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