]> oss.titaniummirror.com Git - dispcfg.git/blobdiff - configure_displays
Place functions before if __name__
[dispcfg.git] / configure_displays
index 40a3ff27134cb73ddea50ce3cddf053ee5a5d5c9..5d122a11dcedb28066c5e9ecdc4a7c9ddc6c26dd 100755 (executable)
@@ -1,10 +1,9 @@
 #!/usr/bin/python
 """
-Parse xrandr current information
+Configure displays by looking at xrandr information
 
-TODO:
-* Cannot seem to undock notebook then recover displays without causing a logout
-  event.  Could it be that i3 is finding there are no displays?
+Select the best 1 or 2 xrandr outputs to use as displays, based on xrandr
+information, then reconfigure outputs via xrandr.
 """
 
 import sys
@@ -108,6 +107,39 @@ def output_by_name(outputs, name):
     return None
 
 
+def print_outputs(header, outputs):
+    print '%s:' % header
+    for output in outputs:
+        print_output(output)
+    print
+
+
+def all_done(outputs):
+    for output in outputs:
+        if not output['done']:
+            return False
+    return True
+
+
+def disable_an_entry(outputs):
+    for output in outputs:
+        if not output['done'] and not output['use'] and output['enabled']:
+            xrandr_off(output)
+            output['done'] = True
+            return 1
+    return 0
+
+
+def enable_an_entry(outputs):
+    enables = 0
+    for output in reversed(outputs):
+        if not output['done'] and output['use']:
+            xrandr_on(output)
+            output['done'] = True
+            return 1
+    return 0
+
+
 if __name__ == '__main__':
     def print_output(output):
         print 'name:%s  connected:%r  enabled:%r  width:%d  height:%d pos:%dx%d' % (
@@ -115,35 +147,6 @@ if __name__ == '__main__':
                 output['width'], output['height'], output['posx'],
                 output['posy'])
 
-    def print_outputs(header, outputs):
-        print '%s:' % header
-        for output in outputs:
-            print_output(output)
-        print
-
-    def all_done(outputs):
-        for output in outputs:
-            if not output['done']:
-                return False
-        return True
-
-    def disable_an_entry(outputs):
-        for output in outputs:
-            if not output['done'] and not output['use'] and output['enabled']:
-                xrandr_off(output)
-                output['done'] = True
-                return 1
-        return 0
-
-    def enable_an_entry(outputs):
-        enables = 0
-        for output in reversed(outputs):
-            if not output['done'] and output['use']:
-                xrandr_on(output)
-                output['done'] = True
-                return 1
-        return 0
-
     def main(argv):
         global dry_run
         if len(argv) >= 2 and argv[1] == '--dry-run':