X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=autorandr.py;h=f3612cb6cca730c1d490eea1cb0924b1b7ffb247;hb=6511ee3cb3d69d0053129ce6584e65570e10f122;hp=57943f7c6c80452eea1d6916b4fe14192a5aee0a;hpb=42c50e502ed30c10c1a2bd3cefe003861963cf61;p=deb_pkgs%2Fautorandr.git diff --git a/autorandr.py b/autorandr.py index 57943f7..f3612cb 100755 --- a/autorandr.py +++ b/autorandr.py @@ -755,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 and "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 @@ -1059,6 +1073,15 @@ def dispatch_call_to_sessions(argv): X11_displays_done.add(display) +def enabled_monitors(config): + monitors = [] + for monitor in config: + if "--off" in config[monitor].option_vector: + continue + monitors.append(monitor) + return monitors + + def read_config(options, directory): """Parse a configuration config.ini from directory and merge it into the options dictionary""" @@ -1161,7 +1184,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(enabled_monitors(config)), + }) 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"]) @@ -1281,6 +1308,7 @@ def main(argv): script_metadata = { "CURRENT_PROFILE": load_profile, "PROFILE_FOLDER": scripts_path, + "MONITORS": ":".join(enabled_monitors(load_config)), } exec_scripts(scripts_path, "preswitch", script_metadata) if "--debug" in options: