add autotime functionality
This commit is contained in:
40
src/fenrir/commands/onScreenUpdate/76000-time.py
Normal file
40
src/fenrir/commands/onScreenUpdate/76000-time.py
Normal file
@ -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
|
||||
|
@ -64,6 +64,10 @@ settings = {
|
||||
'inactiveTimeoutSec': 120,
|
||||
'list': '',
|
||||
},
|
||||
'time':{
|
||||
'enabled': False,
|
||||
'delaySec': 3600,
|
||||
},
|
||||
'keyboard':{
|
||||
'driver': 'evdev',
|
||||
'device': 'all',
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user