From cd1dc49fd242fa3b2219a64aa1c5f7e37a0a5845 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 9 Nov 2016 21:28:18 +0100 Subject: [PATCH] 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