]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Added install makefile and autorandr inotify monitor
authorQueezyTheGreat <queezythegreat@gmail.com>
Wed, 26 Jun 2013 17:33:16 +0000 (19:33 +0200)
committerQueezyTheGreat <queezythegreat@gmail.com>
Wed, 26 Jun 2013 17:33:16 +0000 (19:33 +0200)
Makefile [new file with mode: 0644]
autorandr_monitor [new file with mode: 0755]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..4d871ad
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,7 @@
+
+install:
+       install        auto-disper        /usr/bin/
+       install -m 774 autorandr          /usr/bin/
+       install -m 774 autorandr_monitor  /usr/bin/
+       install -m 644 bash_completion/autorandr /etc/bash_completion.d/
+       #install -m pm-utils/40autorandr /etc/pm/power.d/
diff --git a/autorandr_monitor b/autorandr_monitor
new file mode 100755 (executable)
index 0000000..e1e5259
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+import os
+import pyinotify
+from pyinotify import ProcessEvent
+
+SYS_VIDEO_OUTPUTS='/sys/class/drm/card0/'
+
+DEFAULT_PROFILE='mobile'
+AUTORANDR_CMD='autorandr --change --default %s' % DEFAULT_PROFILE
+
+class VideoOutputMonitor(ProcessEvent):
+
+    def process_IN_ACCESS(self, event):
+        if event.name == 'status':
+            print 'Change status of %s' % os.path.basename(event.path)
+            os.system(AUTORANDR_CMD)
+
+
+def register_video_cards(manager):
+    if not os.path.exists(SYS_VIDEO_OUTPUTS):
+        return
+
+    for directory in os.listdir(SYS_VIDEO_OUTPUTS):
+        path = os.path.join(SYS_VIDEO_OUTPUTS, directory)
+        status = os.path.join(path, 'status')
+        if os.path.exists(status):
+            print 'Monitoring %s' % path
+            manager.add_watch(path, pyinotify.ALL_EVENTS)
+
+# pyinotify.log.setLevel(10)
+
+manager = pyinotify.WatchManager()
+handler = VideoOutputMonitor()
+notifier = pyinotify.Notifier(manager, default_proc_fun=handler)
+
+register_video_cards(manager)
+
+notifier.loop()