fix screen auto ignore

This commit is contained in:
chrys 2017-02-25 01:38:39 +01:00
parent cfc1dffde8
commit 546b44febc
2 changed files with 31 additions and 17 deletions

View File

@ -15,14 +15,14 @@ class screenManager():
self.env = environment self.env = environment
self.env['runtime']['settingsManager'].loadDriver(\ self.env['runtime']['settingsManager'].loadDriver(\
self.env['runtime']['settingsManager'].getSetting('screen', 'driver'), 'screenDriver') self.env['runtime']['settingsManager'].getSetting('screen', 'driver'), 'screenDriver')
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'): self.env['runtime']['screenDriver'].getSessionInformation()
self.autoIgnoreScreens = self.env['runtime']['screenDriver'].getIgnoreScreens()
def shutdown(self): def shutdown(self):
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
def update(self, trigger='onUpdate'): def update(self, trigger='onUpdate'):
self.env['runtime']['screenDriver'].getCurrScreen() self.env['runtime']['screenDriver'].getCurrScreen()
self.env['runtime']['screenDriver'].getSessionInformation()
self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication'] self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication']
if self.isScreenChange(): if self.isScreenChange():
self.changeBrailleScreen() self.changeBrailleScreen()
@ -36,9 +36,13 @@ class screenManager():
def isSuspendingScreen(self, screen = None): def isSuspendingScreen(self, screen = None):
if screen == None: if screen == None:
screen = self.env['screenData']['newTTY'] screen = self.env['screenData']['newTTY']
return ((screen in \ ignoreScreens = []
self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or fixIgnoreScreens = self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen')
(screen in self.autoIgnoreScreens)) if fixIgnoreScreens != '':
ignoreScreens.append(fixIgnoreScreens.split(','))
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
ignoreScreens.extend(self.env['screenData']['autoIgnoreScreens'])
return (screen in ignoreScreens)
def isScreenChange(self): def isScreenChange(self):
if not self.env['screenData']['oldTTY']: if not self.env['screenData']['oldTTY']:

View File

@ -10,6 +10,7 @@ import subprocess
import fcntl import fcntl
import termios import termios
import time import time
import dbus
from core import debug from core import debug
from utils import screen_utils from utils import screen_utils
@ -63,19 +64,28 @@ class driver():
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return return
def getIgnoreScreens(self): def getSessionInformation(self):
xlist = [] progname = 'org.freedesktop.login1'
try: objpath = '/org/freedesktop/login1'
x = subprocess.Popen('ps a -o tty,comm | grep Xorg', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') intfname = 'org.freedesktop.login1.Manager'
except Exception as e: methname = 'ListSessions'
return xlist
for i in x:
if not "grep" in i and \
not "ps" in i:
if (i[:3].lower() == 'tty'):
xlist.append(i[3])
return xlist
bus = dbus.SystemBus()
obj = bus.get_object(progname, objpath)
inf = dbus.Interface(obj, intfname)
meth = inf.get_dbus_method(methname)
sessions = meth()
self.env['screenData']['autoIgnoreScreens'] = []
for session in sessions:
obj = bus.get_object(progname, session[4])
inf = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
sessionType = inf.Get('org.freedesktop.login1.Session', 'Type')
screen = str(inf.Get('org.freedesktop.login1.Session', 'TTY'))
screen = screen[screen.upper().find('TTY') + 3:]
if sessionType.upper() == 'X11':
self.env['screenData']['autoIgnoreScreens'].append(screen)
def update(self, trigger='onUpdate'): def update(self, trigger='onUpdate'):
newContentBytes = b'' newContentBytes = b''