Added install makefile and autorandr inotify monitor

This commit is contained in:
QueezyTheGreat 2013-06-26 19:33:16 +02:00
parent 4f5e2401ef
commit 74a310b76d
2 changed files with 45 additions and 0 deletions

7
Makefile Normal file
View File

@ -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/

38
autorandr_monitor Executable file
View File

@ -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()