X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=autorandr.py;h=2a4ddb7f3baffdf10f6c6d3847ed90c18afec40f;hb=a3e0693ea48225f41222537499dd3eb132f4e5b3;hp=ca761b0e99bd85aaa180b9cba3902004c10821d9;hpb=34f0f21e850b299fa7392dac5277c2000dbc0773;p=deb_pkgs%2Fautorandr.git diff --git a/autorandr.py b/autorandr.py index ca761b0..2a4ddb7 100755 --- a/autorandr.py +++ b/autorandr.py @@ -68,7 +68,7 @@ help_text = """ Usage: autorandr [options] -h, --help get this small help --c, --change reload current setup +-c, --change automatically load the first detected profile -d, --default make profile the default profile -l, --load load profile -s, --save save your current setup to profile @@ -649,6 +649,12 @@ def get_fb_dimensions(configuration): o_left, o_top = map(int, output.options["pos"].split("x")) o_width += o_left o_height += o_top + if "panning" in output.options: + match = re.match("(?P[0-9]+)x(?P[0-9]+)(?:\+(?P[0-9]+))?(?:\+(?P[0-9]+))?.*", output.options["panning"]) + if match: + detail = match.groupdict() + o_width = int(detail.get("w")) + int(detail.get("x", "0")) + o_height = int(detail.get("h")) + int(detail.get("y", "0")) width = max(width, o_width) height = max(height, o_height) return int(width), int(height) @@ -749,10 +755,24 @@ def apply_configuration(new_configuration, current_configuration, dry_run=False) def is_equal_configuration(source_configuration, target_configuration): - "Check if all outputs from target are already configured correctly in source" + """ + Check if all outputs from target are already configured correctly in source and + that no other outputs are active. + """ for output in target_configuration.keys(): - if (output not in source_configuration) or (source_configuration[output] != target_configuration[output]): - return False + if "off" in target_configuration[output].options: + if (output in source_configuration or "off" not in source_configuration[output].options): + return False + else: + if (output not in source_configuration) or (source_configuration[output] != target_configuration[output]): + return False + for output in source_configuration.keys(): + if "off" in source_configuration[output].options: + if output in target_configuration and "off" not in target_configuration.options: + return False + else: + if output not in target_configuration: + return False return True @@ -1155,7 +1175,11 @@ def main(argv): try: profile_folder = os.path.join(profile_path, options["--save"]) save_configuration(profile_folder, config) - exec_scripts(profile_folder, "postsave", {"CURRENT_PROFILE": options["--save"], "PROFILE_FOLDER": profile_folder}) + exec_scripts(profile_folder, "postsave", { + "CURRENT_PROFILE": options["--save"], + "PROFILE_FOLDER": profile_folder, + "MONITORS": ":".join(config.keys()), + }) except Exception as e: raise AutorandrException("Failed to save current configuration as profile '%s'" % (options["--save"],), e) print("Saved current configuration as profile '%s'" % options["--save"]) @@ -1237,7 +1261,7 @@ def main(argv): if "-d" in options: options["--default"] = options["-d"] - if not load_profile and "--default" in options: + if not load_profile and "--default" in options and ("-c" in options or "--change" in options): load_profile = options["--default"] if load_profile: @@ -1275,6 +1299,7 @@ def main(argv): script_metadata = { "CURRENT_PROFILE": load_profile, "PROFILE_FOLDER": scripts_path, + "MONITORS": ":".join(load_config.keys()), } exec_scripts(scripts_path, "preswitch", script_metadata) if "--debug" in options: