]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Merge branch 'master' into debian/sid
authorDon Armstrong <don@donarmstrong.com>
Fri, 22 Dec 2017 18:22:58 +0000 (10:22 -0800)
committerDon Armstrong <don@donarmstrong.com>
Fri, 22 Dec 2017 18:22:58 +0000 (10:22 -0800)
README.md
autorandr.py
setup.py

index bdaf638e7baeeb5e84d19fd68cdae5389b0193f7..7268c427ae64a06918c28ad636e747429cb7a82d 100644 (file)
--- a/README.md
+++ b/README.md
@@ -142,6 +142,10 @@ names in your configuration directory to have autorandr use any of them
 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 
@@ -193,6 +197,12 @@ running `xrandr`.
 
 ## Changelog
 
+**autorandr 1.4**
+
+* *2017-12-22* Fixed broken virtual profile support
+* *2017-12-14* Added support for a settings file
+* *2017-12-14* Added a virtual profile `off`, which disables all screens
+
 **autorandr 1.3**
 
 * *2017-11-13* Add a short form for `--load`
index ba6c5f0fcd708f3842545c793869204576399be9..05b2a5c6c8bed96b8ca7c0e7138a1f049b93529e 100755 (executable)
@@ -42,6 +42,11 @@ from distutils.version import LooseVersion as Version
 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 @@ except NameError:
 
 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),
@@ -762,7 +768,7 @@ def generate_virtual_profile(configuration, modes, profile_name):
         for output in configuration:
             configuration[output].options = {}
             if output in modes and configuration[output].edid:
-                def key(a, b):
+                def key(a):
                     score = int(a["width"]) * int(a["height"])
                     if a["preferred"]:
                         score += 10**6
@@ -782,7 +788,7 @@ def generate_virtual_profile(configuration, modes, profile_name):
         for output in configuration:
             configuration[output].options = {}
             if output in modes and configuration[output].edid:
-                def key(a, b):
+                def key(a):
                     score = int(a["width"]) * int(a["height"])
                     if a["preferred"]:
                         score += 10**6
@@ -799,6 +805,11 @@ def generate_virtual_profile(configuration, modes, profile_name):
                 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,15 @@ def dispatch_call_to_sessions(argv):
             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"))
+    if config.has_section("config"):
+        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 +1060,7 @@ def main(argv):
             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 +1070,7 @@ def main(argv):
         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:
index b4ab17330b3643ebb1f75eda4e1d8bb0628f0f8c..7282c7c45ee05bea8d5f29ddfd5623a486391538 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ except:
 setup(
     name='autorandr',
 
-    version='1.2-1',
+    version='1.4-1',
 
     description='Automatically select a display configuration based on connected devices',
     long_description=long_description,