Usage: autorandr [options]
-h, --help get this small help
--c, --change reload current setup
+-c, --change automatically load the first detected profile
-d, --default <profile> make profile <profile> the default profile
-l, --load <profile> load profile <profile>
-s, --save <profile> save your current setup to profile <profile>
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
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"])
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:
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: