rework ignore screen detection; detect user of current TTY
This commit is contained in:
parent
ef006fb423
commit
abb3823606
@ -108,3 +108,5 @@ KEY_FENRIR,KEY_X=set_mark
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text
|
||||
KEY_FENRIR,KEY_C=copy_marked_to_clipboard
|
||||
KEY_FENRIR,KEY_V=paste_clipboard
|
||||
# linux specific
|
||||
#=export_clipboard_to_x
|
||||
|
@ -108,3 +108,5 @@ KEY_FENRIR,KEY_X=set_mark
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text
|
||||
KEY_FENRIR,KEY_C=copy_marked_to_clipboard
|
||||
KEY_FENRIR,KEY_V=paste_clipboard
|
||||
# linux specific
|
||||
#=export_clipboard_to_x
|
||||
|
@ -11,29 +11,29 @@ KEY_FENRIR,KEY_KP1=review_line_first_char
|
||||
KEY_FENRIR,KEY_KP3=review_line_last_char
|
||||
KEY_FENRIR,KEY_ALT,KEY_1=present_first_line
|
||||
KEY_FENRIR,KEY_ALT,KEY_2=present_last_line
|
||||
#KEY_KP5=review_curr_word
|
||||
#KEY_KP4=review_prev_word
|
||||
#KEY_KP6=review_next_word
|
||||
KEY_KP5=review_curr_word_phonetic
|
||||
KEY_KP4=review_prev_word_phonetic
|
||||
KEY_KP6=review_next_word_phonetic
|
||||
#KEY_KP2=review_curr_char
|
||||
#KEY_KP1=review_prev_char
|
||||
#KEY_KP3=review_next_char
|
||||
#KEY_KP2=review_curr_char_phonetic
|
||||
#KEY_KP1=review_prev_char_phonetic
|
||||
#KEY_KP3=review_next_char_phonetic
|
||||
#=review_up
|
||||
#=review_down
|
||||
KEY_KP5=review_curr_word
|
||||
KEY_KP4=review_prev_word
|
||||
KEY_KP6=review_next_word
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_KP5=review_curr_word_phonetic
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_KP4=review_prev_word_phonetic
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_KP6=review_next_word_phonetic
|
||||
KEY_KP2=review_curr_char
|
||||
KEY_KP1=review_prev_char
|
||||
KEY_KP3=review_next_char
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_KP2=review_curr_char_phonetic
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_KP1=review_prev_char_phonetic
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_KP3=review_next_char_phonetic
|
||||
KEY_FENRIR,KEY_CTRL,KEY_KP8=review_up
|
||||
KEY_FENRIR,KEY_CTRL,KEY_KP2=review_down
|
||||
KEY_KPDOT=cursor_position
|
||||
KEY_FENRIR,KEY_I=indent_curr_line
|
||||
KEY_FENRIR,KEY_KPDOT=exit_review
|
||||
KEY_FENRIR,KEY_KP5=curr_screen
|
||||
#KEY_FENRIR,KEY_KP8=curr_screen_before_cursor
|
||||
#KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
|
||||
KEY_FENRIR,KEY_KP8=curr_screen_before_cursor
|
||||
KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
|
||||
#=cursor_read_to_end_of_line
|
||||
KEY_FENRIR,KEY_KP2=cursor_column
|
||||
KEY_FENRIR,KEY_KP8=cursor_lineno
|
||||
#=cursor_column
|
||||
#=cursor_lineno
|
||||
#=braille_flush
|
||||
#=braille_return_to_cursor
|
||||
#=braille_pan_left
|
||||
@ -73,20 +73,21 @@ KEY_FENRIR,KEY_KPSLASH=set_window_application
|
||||
KEY_KPPLUS=last_incoming
|
||||
KEY_FENRIR,KEY_F2=toggle_braille
|
||||
KEY_FENRIR,KEY_F3=toggle_sound
|
||||
#=toggle_speech
|
||||
KEY_FENRIR,KEY_F4=temp_disable_speech
|
||||
KEY_FENRIR,KEY_F4=toggle_speech
|
||||
KEY_KPENTER=temp_disable_speech
|
||||
KEY_FENRIR,KEY_CTRL,KEY_P=toggle_punctuation_level
|
||||
KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check
|
||||
KEY_FENRIR,KEY_BACKSLASH=toggle_output
|
||||
#=toggle_emoticons
|
||||
KEY_FENRIR,KEY_CTRL,KEY_E=toggle_emoticons
|
||||
key_FENRIR,KEY_KPENTER=toggle_auto_read
|
||||
#=toggle_auto_time
|
||||
#=toggle_highlight_tracking
|
||||
KEY_FENRIR,KEY_CTRL,KEY_T=toggle_auto_time
|
||||
KEY_FENRIR,KEY_KPASTERISK=toggle_highlight_tracking
|
||||
KEY_FENRIR,KEY_Q=quit_fenrir
|
||||
KEY_FENRIR,KEY_T=time
|
||||
2,KEY_FENRIR,KEY_T=date
|
||||
KEY_KP1=add_word_to_spell_check
|
||||
KEY_KP2=remove_word_from_spell_check
|
||||
KEY_FENRIR,KEY_S=spell_check
|
||||
2,KEY_FENRIR,KEY_S=add_word_to_spell_check
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check
|
||||
KEY_FENRIR,KEY_BACKSPACE=forward_keypress
|
||||
KEY_FENRIR,KEY_UP=inc_speech_volume
|
||||
KEY_FENRIR,KEY_DOWN=dec_speech_volume
|
||||
@ -106,4 +107,6 @@ KEY_FENRIR,KEY_SHIFT,KEY_C=curr_clipboard
|
||||
KEY_FENRIR,KEY_X=set_mark
|
||||
KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text
|
||||
KEY_FENRIR,KEY_C=copy_marked_to_clipboard
|
||||
KEY_FENRIR,KEY_V=paste_clipboard
|
||||
#KEY_FENRIR,KEY_V=paste_clipboard
|
||||
# linux specific
|
||||
KEY_FENRIR,KEY_V=export_clipboard_to_x
|
||||
|
56
src/fenrir/commands/commands/export_clipboard_to_x.py
Normal file
56
src/fenrir/commands/commands/export_clipboard_to_x.py
Normal file
@ -0,0 +1,56 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
import subprocess, os
|
||||
from subprocess import Popen, PIPE
|
||||
import _thread
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment, scriptPath=''):
|
||||
self.env = environment
|
||||
self.scriptPath = scriptPath
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'export the current fenrir clipboard to X clipboard'
|
||||
def run(self):
|
||||
_thread.start_new_thread(self._threadRun , ())
|
||||
|
||||
def _threadRun(self):
|
||||
try:
|
||||
currClipboard = self.env['commandBuffer']['currClipboard']
|
||||
if currClipboard < 0:
|
||||
self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
|
||||
return
|
||||
if not self.env['commandBuffer']['clipboard']:
|
||||
self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
|
||||
return
|
||||
if not self.env['commandBuffer']['clipboard'][currClipboard]:
|
||||
self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
|
||||
return
|
||||
if self.env['commandBuffer']['clipboard'][currClipboard] == '':
|
||||
self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
|
||||
return
|
||||
|
||||
p = Popen('su -c "echo -n \"' + self.env['commandBuffer']['clipboard'][currClipboard] +'\" | xclip -selection c' + self.env['generalInformation']['currUser'] , stdout=PIPE, stderr=PIPE, shell=True)
|
||||
stdout, stderr = p.communicate()
|
||||
self.env['runtime']['outputManager'].interruptOutput()
|
||||
screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding')
|
||||
stderr = stderr.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
|
||||
stdout = stdout.decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
|
||||
if stderr != '':
|
||||
self.env['runtime']['outputManager'].presentText(stdout , soundIcon='', interrupt=False)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText('export clipboard', soundIcon='PasteClipboardOnScreen', interrupt=True)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.env['runtime']['outputManager'].presentText(e , soundIcon='', interrupt=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -9,4 +9,6 @@ from core import debug
|
||||
generalInformation = {
|
||||
'running': True,
|
||||
'tutorialMode': False,
|
||||
'currUser':'',
|
||||
'prevUser':'',
|
||||
}
|
||||
|
@ -32,5 +32,6 @@ screenData = {
|
||||
'newContentAttrib': b'',
|
||||
'newTTY':'0',
|
||||
'newApplication': '',
|
||||
'lastScreenUpdate': time.time()
|
||||
'lastScreenUpdate': time.time(),
|
||||
'autoIgnoreScreens':[],
|
||||
}
|
||||
|
@ -9,22 +9,22 @@ import time
|
||||
|
||||
class screenManager():
|
||||
def __init__(self):
|
||||
self.autoIgnoreScreens = []
|
||||
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['runtime']['settingsManager'].loadDriver(\
|
||||
self.env['runtime']['settingsManager'].getSetting('screen', 'driver'), 'screenDriver')
|
||||
self.updateAutoIgnoreScreens()
|
||||
self.env['runtime']['screenDriver'].getCurrScreen()
|
||||
self.env['runtime']['screenDriver'].getSessionInformation()
|
||||
|
||||
def shutdown(self):
|
||||
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
|
||||
|
||||
def update(self, trigger='onUpdate'):
|
||||
self.env['runtime']['screenDriver'].getCurrScreen()
|
||||
self.env['runtime']['screenDriver'].getSessionInformation()
|
||||
self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication']
|
||||
if self.isScreenChange():
|
||||
self.updateAutoIgnoreScreens()
|
||||
if self.isScreenChange():
|
||||
self.changeBrailleScreen()
|
||||
if not self.isSuspendingScreen(self.env['screenData']['newTTY']):
|
||||
self.env['runtime']['screenDriver'].update(trigger)
|
||||
@ -36,12 +36,14 @@ class screenManager():
|
||||
def isSuspendingScreen(self, screen = None):
|
||||
if screen == None:
|
||||
screen = self.env['screenData']['newTTY']
|
||||
return ((screen in \
|
||||
self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or
|
||||
(screen in self.autoIgnoreScreens))
|
||||
def updateAutoIgnoreScreens(self):
|
||||
ignoreScreens = []
|
||||
fixIgnoreScreens = self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen')
|
||||
if fixIgnoreScreens != '':
|
||||
ignoreScreens.append(fixIgnoreScreens.split(','))
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
|
||||
self.autoIgnoreScreens = self.env['runtime']['screenDriver'].getIgnoreScreens()
|
||||
ignoreScreens.append(self.env['screenData']['autoIgnoreScreens'])
|
||||
return (screen in ignoreScreens)
|
||||
|
||||
def isScreenChange(self):
|
||||
if not self.env['screenData']['oldTTY']:
|
||||
return False
|
||||
|
@ -57,14 +57,13 @@ class fenrir():
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
||||
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
||||
self.environment['runtime']['applicationManager'].getPrevApplication(), \
|
||||
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
||||
self.environment['runtime']['screenManager'].updateAutoIgnoreScreens()
|
||||
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
||||
|
||||
if self.environment['runtime']['screenManager'].isScreenChange():
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged')
|
||||
else:
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
|
||||
self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||
self.handleCommands()
|
||||
#print(time.time()-startTime)
|
||||
|
||||
|
@ -10,6 +10,7 @@ import subprocess
|
||||
import fcntl
|
||||
import termios
|
||||
import time
|
||||
import dbus
|
||||
from core import debug
|
||||
from utils import screen_utils
|
||||
|
||||
@ -63,19 +64,34 @@ class driver():
|
||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||
return
|
||||
|
||||
def getIgnoreScreens(self):
|
||||
xlist = []
|
||||
try:
|
||||
x = subprocess.Popen('ps a -o tty,comm | grep Xorg', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n')
|
||||
except Exception as e:
|
||||
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
|
||||
def getSessionInformation(self):
|
||||
sta = time.time()
|
||||
|
||||
progname = 'org.freedesktop.login1'
|
||||
objpath = '/org/freedesktop/login1'
|
||||
intfname = 'org.freedesktop.login1.Manager'
|
||||
methname = 'ListSessions'
|
||||
|
||||
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)
|
||||
if screen == self.env['screenData']['newTTY'] :
|
||||
if self.env['generalInformation']['currUser'] != session[2]:
|
||||
self.env['generalInformation']['prevUser'] = self.env['generalInformation']['currUser']
|
||||
self.env['generalInformation']['currUser'] = session[2]
|
||||
|
||||
def update(self, trigger='onUpdate'):
|
||||
newContentBytes = b''
|
||||
|
Loading…
Reference in New Issue
Block a user