]> oss.titaniummirror.com Git - dispcfg.git/commitdiff
Place functions before if __name__
authorR. Steve McKown <rsmckown@gmail.com>
Fri, 23 Jan 2015 10:29:43 +0000 (03:29 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Fri, 23 Jan 2015 10:30:11 +0000 (03:30 -0700)
README [new file with mode: 0644]
configure_displays

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..390ab85
--- /dev/null
+++ b/README
@@ -0,0 +1,18 @@
+configure_displays should be ran here:
+
+* On resume from suspend
+* On key press from window manager (shortcut) -- currently $mod+p in ~/.i3/config
+* On login startup -- currently ~/.i3/startup
+
+The simple /etc/pm/sleep.d/50_configure-displays script:
+----
+#!/bin/sh
+
+# Configure displays on resume and thaw
+
+case "$1" in
+       resume|thaw)
+               configure_displays
+               ;;
+esac
+----
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':