]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Minor code refactoring
authorQueezyTheGreat <queezythegreat@gmail.com>
Wed, 26 Jun 2013 18:09:14 +0000 (20:09 +0200)
committerQueezyTheGreat <queezythegreat@gmail.com>
Wed, 26 Jun 2013 18:09:14 +0000 (20:09 +0200)
Makefile
Xsession.d/autorandr [new file with mode: 0644]
autorandr_monitor

index 8a45be58ef580e453acbc54a84a728771486583c..a8ee74ae0f8e12cd70506726525f847a45500d1b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,4 +4,5 @@ install:
        install -m 774 autorandr_monitor  /usr/bin/
        install -m 644 bash_completion/autorandr /etc/bash_completion.d/
        ln -sf /usr/bin/autorandr /usr/bin/auto-disper
-       #install -m pm-utils/40autorandr /etc/pm/power.d/
+       #install -m 644 /etc/X11/Xsession.d/
+       #install -m 644 pm-utils/40autorandr /etc/pm/power.d/
diff --git a/Xsession.d/autorandr b/Xsession.d/autorandr
new file mode 100644 (file)
index 0000000..06e9d2b
--- /dev/null
@@ -0,0 +1,3 @@
+# -*- sh -*-
+
+autorandr_mointor > /tmp/autorandr_monitor &
index 245b4ddc10b277541e993cfeb4f65b00f886ac1d..6f369bb3d48c0e86656d6dd5f5ba4cd49f63961d 100755 (executable)
@@ -1,23 +1,34 @@
 #!/usr/bin/env python
+""""
+Author:  Tomasz Bogdal (a.k.a. QueezyTheGreat)
+Home:    https://github.com/queezythegreat/autorandr
+License: This Source Code Form is subject to the terms of the
+         Mozilla Public License, v. 2.0
+"""
 import os
 import pyinotify
 from pyinotify import ProcessEvent
 
-SYS_VIDEO_OUTPUTS='/sys/class/drm/card0/'
-SYS_VIDEO_OUTPUTS='/sys/class/drm/'
+#TODO: Fork off when started
+#TODO: Add configuration file
+#TODO: Add command line options
 
+SYS_VIDEO_OUTPUTS='/sys/class/drm/'
 DEFAULT_PROFILE='default'
 AUTORANDR_CMD='autorandr --change --default %s' % DEFAULT_PROFILE
 
 class VideoOutputMonitor(ProcessEvent):
+    """ Launch autorandr when video card output status is changed. """
 
     def process_IN_ACCESS(self, event):
+        """ Handle IN_ACCESS events to `status` file. """
         if event.name == 'status':
             print 'Change status of %s' % os.path.basename(event.path)
             os.system(AUTORANDR_CMD)
 
 
 def register_video_cards(manager):
+    """ Register all video card ouptus for monitoring. """
     if not os.path.exists(SYS_VIDEO_OUTPUTS):
         return
 
@@ -28,12 +39,15 @@ def register_video_cards(manager):
             print 'Monitoring %s' % path
             manager.add_watch(path, pyinotify.ALL_EVENTS)
 
-# pyinotify.log.setLevel(10)
+def main():
+    # pyinotify.log.setLevel(10)
+    manager = pyinotify.WatchManager()
+    handler = VideoOutputMonitor()
+    notifier = pyinotify.Notifier(manager, default_proc_fun=handler)
 
-manager = pyinotify.WatchManager()
-handler = VideoOutputMonitor()
-notifier = pyinotify.Notifier(manager, default_proc_fun=handler)
+    register_video_cards(manager)
 
-register_video_cards(manager)
+    notifier.loop()
 
-notifier.loop()
+if __name__ == '__main__':
+    main()