]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Refactor: merge --change and --cycle handling
authorMikel Ward <mbw@google.com>
Tue, 9 Mar 2021 16:18:54 +0000 (08:18 -0800)
committerMikel Ward <mbw@google.com>
Tue, 9 Mar 2021 16:18:54 +0000 (08:18 -0800)
autorandr.py

index 1969a00b873702bc696dfcb28c562201268b4830..0581f57c781112ef70db1754e9223e85e504a02f 100755 (executable)
@@ -1375,6 +1375,7 @@ def main(argv):
                     print("%s (blocked)" % profile_name)
                 continue
             props = []
+            is_current_profile = profile_name in current_profiles
             if profile_name in detected_profiles:
                 if len(detected_profiles) == 1:
                     index = 1
@@ -1382,16 +1383,13 @@ def main(argv):
                 else:
                     index = detected_profiles.index(profile_name) + 1
                     props.append("(detected) (%d%s match)" % (index, ["st", "nd", "rd"][index - 1] if index < 4 else "th"))
-                if ("-c" in options or "--change" in options) and index < best_index:
-                    load_profile = profile_name
-                    best_index = index
-                if "--cycle" in options and index < best_index:
-                    if profile_name not in current_profiles:
+                if index < best_index:
+                    if "-c" in options or "--change" in options or ("--cycle" in options and not is_current_profile):
                         load_profile = profile_name
                         best_index = index
             elif "--detected" in options:
                 continue
-            if profile_name in current_profiles:
+            if is_current_profile:
                 props.append("(current)")
             elif "--current" in options:
                 continue