else:
import configparser
-__version__ = "1.5"
+__version__ = "1.7"
try:
input = raw_input
x = (a * o_width + b * o_height + c) / w
y = (d * o_width + e * o_height + f) / w
o_width, o_height = x, y
+ if "rotate" in output.options:
+ if output.options["rotate"] in ("left", "right"):
+ o_width, o_height = o_height, o_width
if "pos" in output.options:
o_left, o_top = map(int, output.options["pos"].split("x"))
o_width += o_left
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[output].options:
+ return False
+ else:
+ if output not in target_configuration:
+ return False
return True
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"""
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"])
if "-d" in options:
options["--default"] = options["-d"]
- if not load_profile and "--default" in options and "--change" 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:
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: