]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - debian/patches/settings_ini
Add patch for missing config section in settings.ini from upstream
[deb_pkgs/autorandr.git] / debian / patches / settings_ini
1 --- a/README.md
2 +++ b/README.md
3 @@ -142,6 +142,10 @@
4  as the default configuration without you having to change the system-wide
5  configuration.
6  
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.
10 +
11  ## Hook scripts
12  
13  Three more scripts can be placed in the configuration directory (as 
14 --- a/autorandr.py
15 +++ b/autorandr.py
16 @@ -42,6 +42,11 @@
17  from functools import reduce
18  from itertools import chain
19  
20 +if sys.version_info.major == 2:
21 +    import ConfigParser as configparser
22 +else:
23 +    import configparser
24 +
25  try:
26      input = raw_input
27  except NameError:
28 @@ -49,6 +54,7 @@
29  
30  virtual_profiles = [
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),
36 @@ -799,6 +805,11 @@
37                  configuration[output].options["transform"] = "{},0,{},0,{},{},0,0,1".format(scale, mov_x, scale, mov_y)
38              else:
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
45      return configuration
46  
47  
48 @@ -1002,6 +1013,15 @@
49              X11_displays_done.add(display)
50  
51  
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)
60 +
61  def main(argv):
62      try:
63          opts, args = getopt.getopt(argv[1:], "s:r:l:d:cfh",
64 @@ -1040,6 +1060,7 @@
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")
72 @@ -1049,6 +1070,7 @@
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: