From c1b4f825871d9873bf0ebb09d63bc8b57c19439d Mon Sep 17 00:00:00 2001 From: chrys87 Date: Wed, 9 Nov 2016 10:33:07 +0100 Subject: [PATCH 1/6] Update TODO --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index f5227b30..a9ac7eff 100644 --- a/TODO +++ b/TODO @@ -8,6 +8,7 @@ ToDos in Priority order: in special cases next word skipps a word, "word<12 spaces>word2<12 spaces>word3 (storm_dragon) spellcheck triggers twice if there are two spaces after an word and you arrow over them fenrir is not able to detect the current application inside of screen. + ps -e -H -o pid,pgrp,pid,ppid,cmd - implement onScreenUpdate commands read highlighted text mode From 9233c1720c7d1d4104cfecbda5d604c34816e1fa Mon Sep 17 00:00:00 2001 From: chrys87 Date: Wed, 9 Nov 2016 15:59:59 +0100 Subject: [PATCH 2/6] Update TODO --- TODO | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO b/TODO index a9ac7eff..1b531e6b 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,9 @@ ToDos in Priority order: spellcheck triggers twice if there are two spaces after an word and you arrow over them fenrir is not able to detect the current application inside of screen. ps -e -H -o pid,pgrp,pid,ppid,cmd + http://stackoverflow.com/questions/24861351/how-to-detect-if-python-script-is-being-run-as-a-background-process/24862213 + fd = open("/dev/tty") + os.tcgetpgrp(fd) - implement onScreenUpdate commands read highlighted text mode From cd1dc49fd242fa3b2219a64aa1c5f7e37a0a5845 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 9 Nov 2016 21:28:18 +0100 Subject: [PATCH 3/6] add autotime functionality --- config/settings/espeak.settings.conf | 4 +- config/settings/settings.conf | 6 +++ config/settings/settings.conf.chrys | 4 +- config/settings/settings.conf.storm | 5 ++- .../commands/onScreenUpdate/76000-time.py | 40 +++++++++++++++++++ src/fenrir/core/settings.py | 4 ++ src/fenrir/fenrir.py | 1 + 7 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 src/fenrir/commands/onScreenUpdate/76000-time.py diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index e11f0a35..8ba3eef1 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -121,4 +121,6 @@ enabled=True inactiveTimeoutSec=120 list= - +[time] +enabled=False +delaySec=3600 diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 8a9f676b..a44a1de4 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -123,4 +123,10 @@ enabled=True inactiveTimeoutSec=120 list= +[time] +# automatic time anouncement +enabled=True +# present time after x seconds +delaySec=3600 + diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index ba13d46a..10dc89c7 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -123,4 +123,6 @@ enabled=True inactiveTimeoutSec=120 list= - +[time] +enabled=False +delaySec=3600 diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 4d2a2c3a..6be9f982 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -68,8 +68,11 @@ cursor=True #follow highlighted text changes highlight=False - [promote] enabled=True inactiveTimeoutSec=120 list= + +[time] +enabled=False +delaySec=3600 diff --git a/src/fenrir/commands/onScreenUpdate/76000-time.py b/src/fenrir/commands/onScreenUpdate/76000-time.py new file mode 100644 index 00000000..10ac2272 --- /dev/null +++ b/src/fenrir/commands/onScreenUpdate/76000-time.py @@ -0,0 +1,40 @@ +#!/bin/python +import time +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from core import debug +import time +import datetime + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + self.lastTime = time.time() + def shutdown(self): + pass + def getDescription(self): + return 'No Description found' + + def run(self): + if not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'): + return + if int(time.time() - self.lastTime) < self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec'): + return + timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat') + + # get the time formatted + timeString = datetime.datetime.strftime(datetime.datetime.now(), timeFormat) + + # present the time + self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False) + + self.lastTime = time.time() + + def setCallback(self, callback): + pass + diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 6355147e..5468a968 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -64,6 +64,10 @@ settings = { 'inactiveTimeoutSec': 120, 'list': '', }, +'time':{ + 'enabled': False, + 'delaySec': 3600, +}, 'keyboard':{ 'driver': 'evdev', 'device': 'all', diff --git a/src/fenrir/fenrir.py b/src/fenrir/fenrir.py index 2073414c..6a9389f9 100644 --- a/src/fenrir/fenrir.py +++ b/src/fenrir/fenrir.py @@ -69,6 +69,7 @@ class fenrir(): def prepareCommand(self): if self.environment['runtime']['screenManager'].isSuspendingScreen(): + self.wasCommand = False return if self.environment['runtime']['inputManager'].noKeyPressed(): return From 9e9bbd4960587ae96e660549c8873568b83b9a99 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 9 Nov 2016 21:33:59 +0100 Subject: [PATCH 4/6] update ToDo, ps example --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 1b531e6b..6a7286b0 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,7 @@ ToDos in Priority order: in special cases next word skipps a word, "word<12 spaces>word2<12 spaces>word3 (storm_dragon) spellcheck triggers twice if there are two spaces after an word and you arrow over them fenrir is not able to detect the current application inside of screen. - ps -e -H -o pid,pgrp,pid,ppid,cmd + ps -e -H -o pid,pgrp,ppid,tty,cmd http://stackoverflow.com/questions/24861351/how-to-detect-if-python-script-is-being-run-as-a-background-process/24862213 fd = open("/dev/tty") os.tcgetpgrp(fd) From 90ebbaf749b9a6dd5c91886bc66cc7502f779fdd Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 9 Nov 2016 21:41:06 +0100 Subject: [PATCH 5/6] improve example --- TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TODO b/TODO index 6a7286b0..e6ecc15f 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,7 @@ ToDos in Priority order: fenrir is not able to detect the current application inside of screen. ps -e -H -o pid,pgrp,ppid,tty,cmd http://stackoverflow.com/questions/24861351/how-to-detect-if-python-script-is-being-run-as-a-background-process/24862213 - fd = open("/dev/tty") + fd = os.open("/dev/tty5", os.O_RDONLY ) os.tcgetpgrp(fd) - implement onScreenUpdate commands From 3171018e6e52c794d925e3a8b1013ee744b19fb1 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 9 Nov 2016 23:17:58 +0100 Subject: [PATCH 6/6] add autotime toggle, announce date on change, make configurable what is spoken date or time or both --- config/keyboard/desktop.conf | 1 + config/keyboard/laptop.conf | 1 + config/keyboard/test.conf | 1 + config/settings/espeak.settings.conf | 2 ++ config/settings/settings.conf | 8 +++--- config/settings/settings.conf.chrys | 6 +++++ config/settings/settings.conf.storm | 6 +++++ .../commands/commands/toggle_auto_time.py | 26 +++++++++++++++++++ .../commands/onScreenUpdate/76000-time.py | 24 ++++++++++------- src/fenrir/core/settings.py | 2 ++ 10 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 src/fenrir/commands/commands/toggle_auto_time.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 0eb82837..df260a4a 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output KEY_FENRIR,KEY_CTRL,KEY_E=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read +#=toggle_auto_time KEY_FENRIR,KEY_KPASTERISK=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index be214ad7..27caf6e8 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_SHIFT,KEY_ENTER=toggle_output KEY_FENRIR,KEY_SHIFT,KEY_E=toggle_emoticons KEY_FENRIR,KEY_ENTER=toggle_auto_read +#=toggle_auto_time KEY_FENRIR,KEY_Y=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 2c1e4867..4cea5c5b 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output #=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read +#=toggle_auto_time #=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 8ba3eef1..3e8183ba 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -123,4 +123,6 @@ list= [time] enabled=False +presentTime=True +presentDate=True delaySec=3600 diff --git a/config/settings/settings.conf b/config/settings/settings.conf index a44a1de4..c3b007f5 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -125,8 +125,10 @@ list= [time] # automatic time anouncement -enabled=True +enabled=False +# present time +presentTime=True +# present date (on change) +presentDate=True # present time after x seconds delaySec=3600 - - diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index 10dc89c7..82861dfb 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -124,5 +124,11 @@ inactiveTimeoutSec=120 list= [time] +# automatic time anouncement enabled=False +# present time +presentTime=True +# present date (on change) +presentDate=True +# present time after x seconds delaySec=3600 diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 6be9f982..5b47566f 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -74,5 +74,11 @@ inactiveTimeoutSec=120 list= [time] +# automatic time anouncement enabled=False +# present time +presentTime=True +# present date (on change) +presentDate=True +# present time after x seconds delaySec=3600 diff --git a/src/fenrir/commands/commands/toggle_auto_time.py b/src/fenrir/commands/commands/toggle_auto_time.py new file mode 100644 index 00000000..98f7c5d3 --- /dev/null +++ b/src/fenrir/commands/commands/toggle_auto_time.py @@ -0,0 +1,26 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from core import debug +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return 'enables or disables automatic reading of time after an period' + + def run(self): + self.env['runtime']['settingsManager'].setSetting('time', 'enabled', str(not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'))) + if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'): + self.env['runtime']['outputManager'].presentText("autotime enabled", soundIcon='', interrupt=True) + else: + self.env['runtime']['outputManager'].presentText("autotime disabled", soundIcon='', interrupt=True) + + def setCallback(self, callback): + pass diff --git a/src/fenrir/commands/onScreenUpdate/76000-time.py b/src/fenrir/commands/onScreenUpdate/76000-time.py index 10ac2272..f63461e8 100644 --- a/src/fenrir/commands/onScreenUpdate/76000-time.py +++ b/src/fenrir/commands/onScreenUpdate/76000-time.py @@ -15,6 +15,8 @@ class command(): def initialize(self, environment): self.env = environment self.lastTime = time.time() + self.lastDateString = '' + self.lastTimeString = '' def shutdown(self): pass def getDescription(self): @@ -26,15 +28,19 @@ class command(): if int(time.time() - self.lastTime) < self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec'): return timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat') - - # get the time formatted timeString = datetime.datetime.strftime(datetime.datetime.now(), timeFormat) - - # present the time - self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False) - - self.lastTime = time.time() - + + dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat') + dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat) + if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime'): + # present the time + self.env['runtime']['outputManager'].presentText('Autotime: ' + timeString , soundIcon='', interrupt=False) + # and date if changes + if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentDate'): + if self.lastDateString != dateString: + self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=False) + self.lastDateString = dateString + self.lastTime = time.time() + self.lastTimeString = timeString def setCallback(self, callback): pass - diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 5468a968..fab91ada 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -66,6 +66,8 @@ settings = { }, 'time':{ 'enabled': False, + 'presentTime': True, + 'presentDate': True, 'delaySec': 3600, }, 'keyboard':{