]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
cherrypick settings.ini patch from upstream
authorDon Armstrong <don@donarmstrong.com>
Thu, 14 Dec 2017 19:02:20 +0000 (11:02 -0800)
committerDon Armstrong <don@donarmstrong.com>
Thu, 14 Dec 2017 19:02:20 +0000 (11:02 -0800)
debian/changelog
debian/patches/series [new file with mode: 0644]
debian/patches/settings_ini [new file with mode: 0644]

index 47b2baaa264a4385d14768835928d918f7e81c7b..9fff8575e6e8638ec07fc95fd9cdda7743390bf4 100644 (file)
@@ -1,6 +1,7 @@
 autorandr (1.3-1) unstable; urgency=medium
 
   * New upstream release
+  * Cherrypick settings.ini patch from upstream
 
  -- Don Armstrong <don@debian.org>  Mon, 11 Dec 2017 10:49:57 -0800
 
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644 (file)
index 0000000..97c8b8a
--- /dev/null
@@ -0,0 +1 @@
+settings_ini
diff --git a/debian/patches/settings_ini b/debian/patches/settings_ini
new file mode 100644 (file)
index 0000000..65f6891
--- /dev/null
@@ -0,0 +1,78 @@
+--- a/README.md
++++ b/README.md
+@@ -142,6 +142,10 @@
+ as the default configuration without you having to change the system-wide
+ configuration.
++You can store default values for any option in an INI-file in
++`~/config/autorandr/settings.ini` in a section `config`. The most useful
++candidate for doing that is `skip-options`, if you need it.
++
+ ## Hook scripts
+ Three more scripts can be placed in the configuration directory (as 
+--- a/autorandr.py
++++ b/autorandr.py
+@@ -42,6 +42,11 @@
+ from functools import reduce
+ from itertools import chain
++if sys.version_info.major == 2:
++    import ConfigParser as configparser
++else:
++    import configparser
++
+ try:
+     input = raw_input
+ except NameError:
+@@ -49,6 +54,7 @@
+ virtual_profiles = [
+     # (name, description, callback)
++    ("off", "Disable all outputs", None),
+     ("common", "Clone all connected outputs at the largest common resolution", None),
+     ("clone-largest", "Clone all connected outputs with the largest resolution (scaled down if necessary)", None),
+     ("horizontal", "Stack all connected outputs horizontally at their largest resolution", None),
+@@ -799,6 +805,11 @@
+                 configuration[output].options["transform"] = "{},0,{},0,{},{},0,0,1".format(scale, mov_x, scale, mov_y)
+             else:
+                 configuration[output].options["off"] = None
++    elif profile_name == "off":
++        for output in configuration:
++            for key in list(configuration[output].options.keys()):
++                del configuration[output].options[key]
++            configuration[output].options["off"] = None
+     return configuration
+@@ -1002,6 +1013,14 @@
+             X11_displays_done.add(display)
++def read_config(options, directory):
++    """Parse a configuration config.ini from directory and merge it into
++    the options dictionary"""
++    config = configparser.ConfigParser()
++    config.read(os.path.join(directory, "settings.ini"))
++    for key, value in config.items("config"):
++        options.setdefault("--%s" % key, value)
++
+ def main(argv):
+     try:
+         opts, args = getopt.getopt(argv[1:], "s:r:l:d:cfh",
+@@ -1040,6 +1059,7 @@
+             if os.path.isdir(system_profile_path):
+                 profiles.update(load_profiles(system_profile_path))
+                 profile_symlinks.update(get_symlinks(system_profile_path))
++                read_config(options, system_profile_path)
+         # For the user's profiles, prefer the legacy ~/.autorandr if it already exists
+         # profile_path is also used later on to store configurations
+         profile_path = os.path.expanduser("~/.autorandr")
+@@ -1049,6 +1069,7 @@
+         if os.path.isdir(profile_path):
+             profiles.update(load_profiles(profile_path))
+             profile_symlinks.update(get_symlinks(profile_path))
++            read_config(options, profile_path)
+         # Sort by descending mtime
+         profiles = OrderedDict(sorted(profiles.items(), key=lambda x: -x[1]["config-mtime"]))
+     except Exception as e: