]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
create `--ignore-lid` flag
authoraviau <alexandre@alexandreviau.net>
Sun, 9 Jan 2022 17:57:42 +0000 (12:57 -0500)
committeraviau <alexandre@alexandreviau.net>
Sun, 9 Jan 2022 17:58:45 +0000 (12:58 -0500)
README.md
autorandr.1
autorandr.py

index e66f9da7787e9335192ed822a2183854b85701c8..d13080c1f28f779d4ac7479792b2589e69862110 100644 (file)
--- a/README.md
+++ b/README.md
@@ -58,6 +58,7 @@ Contributors to this version of autorandr are:
 * Tomasz Bogdal
 * Victor Häggqvist
 * Jan-Oliver Kaiser
+* Alexandre Viau
 
 ## Installation/removal
 
index d20264b920e3963db2fb3d21a95d9e558f297608..4e7d4d1bb81f5cc3db09c733ad25fc290c102a83 100644 (file)
@@ -56,6 +56,9 @@ Fingerprint the current hardware setup
 .BR \-\-match-edid
 Match displays based on edid instead of name
 .TP
+.BR \-\-ignore-lid
+By default, closed lids are considered as disconnected if other outputs are detected. This flag disables this behaviour.
+.TP
 .BR \-\-force
 Force loading or reloading of a profile
 .TP
index 6d0163c0a4dc9fd1f207865101206dae00915ec1..b7940bc23c4eeaa5d6926118678298d82fcde914 100755 (executable)
@@ -541,7 +541,10 @@ def debug_regexp(pattern, string):
     return "Debug information would be available if the `regex' module was installed."
 
 
-def parse_xrandr_output():
+def parse_xrandr_output(
+    *,
+    ignore_lid,
+):
     "Parse the output of `xrandr --verbose' into a list of outputs"
     xrandr_output = os.popen("xrandr -q --verbose").read()
     if not xrandr_output:
@@ -564,7 +567,11 @@ def parse_xrandr_output():
             modes[output_name] = output_modes
 
     # consider a closed lid as disconnected if other outputs are connected
-    if sum(o.edid != None for o in outputs.values()) > 1:
+    if not ignore_lid and sum(
+        o.edid != None
+        for o
+        in outputs.values()
+    ) > 1:
         for output_name in outputs.keys():
             if is_closed_lid(output_name):
                 outputs[output_name].edid = None
@@ -1281,10 +1288,32 @@ def read_config(options, directory):
 
 def main(argv):
     try:
-        opts, args = getopt.getopt(argv[1:], "s:r:l:d:cfh",
-                                   ["batch", "dry-run", "change", "cycle", "default=", "save=", "remove=", "load=",
-                                    "force", "fingerprint", "config", "debug", "skip-options=", "help",
-                                    "list", "current", "detected", "version", "match-edid"])
+        opts, args = getopt.getopt(
+            argv[1:],
+            "s:r:l:d:cfh",
+            [
+                "batch",
+                "dry-run",
+                "change",
+                "cycle",
+                "default=",
+                "save=",
+                "remove=",
+                "load=",
+                "force",
+                "fingerprint",
+                "config",
+                "debug",
+                "skip-options=",
+                "help",
+                "list",
+                "current",
+                "detected",
+                "version",
+                "match-edid",
+                "ignore-lid"
+            ]
+        )
     except getopt.GetoptError as e:
         print("Failed to parse options: {0}.\n"
               "Use --help to get usage information.".format(str(e)),
@@ -1341,7 +1370,12 @@ def main(argv):
         raise AutorandrException("Failed to load profiles", e)
 
     exec_scripts(None, "predetect")
-    config, modes = parse_xrandr_output()
+
+    ignore_lid = "--ignore-lid" in options
+
+    config, modes = parse_xrandr_output(
+        ignore_lid=ignore_lid,
+    )
 
     if "--match-edid" in options:
         update_profiles_edid(profiles, config)
@@ -1533,7 +1567,9 @@ def main(argv):
             raise AutorandrException("Failed to apply profile '%s'" % load_profile, e, True)
 
         if "--dry-run" not in options and "--debug" in options:
-            new_config, _ = parse_xrandr_output()
+            new_config, _ = parse_xrandr_output(
+                ignore_lid=ignore_lid,
+            )
             if not is_equal_configuration(new_config, load_config):
                 print("The configuration change did not go as expected:")
                 print_profile_differences(new_config, load_config)