]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blobdiff - autorandr.py
Transformation matrices can contain negative indices
[deb_pkgs/autorandr.git] / autorandr.py
index 99ce9db2940001dce383c0d8122c47990bb2f728..c14e6d289d6637d0414a4f4a8a835186fed4b143 100755 (executable)
@@ -95,7 +95,7 @@ class XrandrOutput(object):
         ).*
         (?:\s*(?:                                                                       # Properties of the output
             Gamma: (?P<gamma>[0-9\.:\s]+) |                                             # Gamma value
-            Transform: (?P<transform>[0-9\.\s]+) |                                      # Transformation matrix
+            Transform: (?P<transform>[\-0-9\.\s]+) |                                    # Transformation matrix
             EDID: (?P<edid>[0-9a-f\s]+) |                                               # EDID of the output
             (?![0-9])[^:\s][^:\n]+:.*(?:\s\\t[\\t ].+)*                                 # Other properties
         ))+
@@ -497,19 +497,21 @@ def main(argv):
         print(str(e))
         options = { "--help": True }
 
-    profile_dir = os.path.expanduser("~/.autorandr")
-    if not os.path.isdir(profile_dir):
-        profile_dir = os.path.join(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "autorandr")
-
-    profile_path = os.path.join(profile_dir, "profiles")
-
+    profiles = {}
     try:
-        profiles = load_profiles(profile_path)
-    except OSError as e:
-        if e.errno == 2: # No such file or directory
-            profiles = {}
-        else:
-            raise e
+        # Load profiles from each XDG config directory
+        for directory in os.environ.get("XDG_CONFIG_DIRS", "").split(":"):
+            system_profile_path = os.path.join(directory, "autorandr")
+            if os.path.isdir(system_profile_path):
+                profiles.update(load_profiles(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")
+        if not os.path.isdir(profile_path):
+            # Elsewise, follow the XDG specification
+            profile_path = os.path.join(os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), "autorandr")
+        if os.path.isdir(profile_path):
+            profiles.update(load_profiles(profile_path))
     except Exception as e:
         print("Failed to load profiles:\n%s" % str(e), file=sys.stderr)
         sys.exit(1)