X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=autorandr.py;h=0d80bc4da2c4164037f8c8c521c98c16a24cd83d;hb=4db718e759e8a1c8cf40fba21a920669a0ed6b58;hp=9f3384c1a80088e4a5ebf207dd91a9b5a6e34d1d;hpb=caba4885832abb1086b09c7b9253a587866dd70a;p=deb_pkgs%2Fautorandr.git diff --git a/autorandr.py b/autorandr.py index 9f3384c..0d80bc4 100755 --- a/autorandr.py +++ b/autorandr.py @@ -28,6 +28,7 @@ import binascii import copy import getopt import hashlib +import math import os import posix import pwd @@ -324,6 +325,8 @@ class XrandrOutput(object): def parse_serial_from_edid(self): self.serial = None if self.edid: + if self.EDID_UNAVAILABLE in self.edid: + return # Thx to pyedid project, the following code was # copied (and modified) from pyedid/__init__py:21 [parse_edid()] raw = bytes.fromhex(self.edid) @@ -465,7 +468,7 @@ class XrandrOutput(object): return XrandrOutput(match["output"], edid, options), modes @classmethod - def from_config_file(cls, edid_map, configuration): + def from_config_file(cls, profile, edid_map, configuration): "Instanciate an XrandrOutput from the contents of a configuration file" options = {} for line in configuration.split("\n"): @@ -486,8 +489,8 @@ class XrandrOutput(object): if fuzzy_output in fuzzy_edid_map: edid = edid_map[list(edid_map.keys())[fuzzy_edid_map.index(fuzzy_output)]] elif "off" not in options: - raise AutorandrException("Failed to find an EDID for output `%s' in setup file, required as `%s' " - "is not off in config file." % (options["output"], options["output"])) + raise AutorandrException("Profile `%s': Failed to find an EDID for output `%s' in setup file, required " + "as `%s' is not off in config file." % (profile, options["output"], options["output"])) output = options["output"] del options["output"] @@ -633,7 +636,7 @@ def load_profiles(profile_path): buffer = [] for line in chain(open(config_name).readlines(), ["output"]): if line[:6] == "output" and buffer: - config[buffer[0].strip().split()[-1]] = XrandrOutput.from_config_file(edids, "".join(buffer)) + config[buffer[0].strip().split()[-1]] = XrandrOutput.from_config_file(profile, edids, "".join(buffer)) buffer = [line] else: buffer.append(line) @@ -855,7 +858,7 @@ def get_fb_dimensions(configuration): o_height = int(detail.get("h")) + int(detail.get("y")) width = max(width, o_width) height = max(height, o_height) - return int(width), int(height) + return math.ceil(width), math.ceil(height) def apply_configuration(new_configuration, current_configuration, dry_run=False): @@ -888,10 +891,10 @@ def apply_configuration(new_configuration, current_configuration, dry_run=False) fb_dimensions = get_fb_dimensions(new_configuration) try: - base_argv += ["--fb", "%dx%d" % fb_dimensions] + fb_args = ["--fb", "%dx%d" % fb_dimensions] except: # Failed to obtain frame-buffer size. Doesn't matter, xrandr will choose for the user. - pass + fb_args = [] auxiliary_changes_pre = [] disable_outputs = [] @@ -941,6 +944,11 @@ def apply_configuration(new_configuration, current_configuration, dry_run=False) if call_and_retry(argv, dry_run=dry_run) != 0: raise AutorandrException("Command failed: %s" % " ".join(argv)) + # Starting here, fix the frame buffer size + # Do not do this earlier, as disabling scaling might temporarily make the framebuffer + # dimensions larger than they will finally be. + base_argv += fb_args + # Disable unused outputs, but make sure that there always is at least one active screen disable_keep = 0 if remain_active_count else 1 if len(disable_outputs) > disable_keep: