4 as the default configuration without you having to change the system-wide
7 +You can store default values for any option in an INI-file in
8 +`~/config/autorandr/settings.ini` in a section `config`. The most useful
9 +candidate for doing that is `skip-options`, if you need it.
13 Three more scripts can be placed in the configuration directory (as
17 from functools import reduce
18 from itertools import chain
20 +if sys.version_info.major == 2:
21 + import ConfigParser as configparser
31 # (name, description, callback)
32 + ("off", "Disable all outputs", None),
33 ("common", "Clone all connected outputs at the largest common resolution", None),
34 ("clone-largest", "Clone all connected outputs with the largest resolution (scaled down if necessary)", None),
35 ("horizontal", "Stack all connected outputs horizontally at their largest resolution", None),
37 configuration[output].options["transform"] = "{},0,{},0,{},{},0,0,1".format(scale, mov_x, scale, mov_y)
39 configuration[output].options["off"] = None
40 + elif profile_name == "off":
41 + for output in configuration:
42 + for key in list(configuration[output].options.keys()):
43 + del configuration[output].options[key]
44 + configuration[output].options["off"] = None
48 @@ -1002,6 +1013,15 @@
49 X11_displays_done.add(display)
52 +def read_config(options, directory):
53 + """Parse a configuration config.ini from directory and merge it into
54 + the options dictionary"""
55 + config = configparser.ConfigParser()
56 + config.read(os.path.join(directory, "settings.ini"))
57 + if config.has_section("config"):
58 + for key, value in config.items("config"):
59 + options.setdefault("--%s" % key, value)
63 opts, args = getopt.getopt(argv[1:], "s:r:l:d:cfh",
65 if os.path.isdir(system_profile_path):
66 profiles.update(load_profiles(system_profile_path))
67 profile_symlinks.update(get_symlinks(system_profile_path))
68 + read_config(options, system_profile_path)
69 # For the user's profiles, prefer the legacy ~/.autorandr if it already exists
70 # profile_path is also used later on to store configurations
71 profile_path = os.path.expanduser("~/.autorandr")
73 if os.path.isdir(profile_path):
74 profiles.update(load_profiles(profile_path))
75 profile_symlinks.update(get_symlinks(profile_path))
76 + read_config(options, profile_path)
77 # Sort by descending mtime
78 profiles = OrderedDict(sorted(profiles.items(), key=lambda x: -x[1]["config-mtime"]))
79 except Exception as e: