2016-08-19 17:22:08 +02:00
|
|
|
#!/bin/python
|
|
|
|
import time
|
|
|
|
|
|
|
|
class command():
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
2016-09-02 21:37:36 +02:00
|
|
|
def initialize(self, environment):
|
2016-09-19 20:34:01 +02:00
|
|
|
pass
|
2016-09-02 21:37:36 +02:00
|
|
|
def shutdown(self, environment):
|
2016-09-19 20:34:01 +02:00
|
|
|
pass
|
2016-09-17 02:14:11 +02:00
|
|
|
def getDescription(self, environment):
|
2016-09-02 21:37:36 +02:00
|
|
|
return ''
|
2016-09-17 02:14:11 +02:00
|
|
|
|
2016-08-19 17:22:08 +02:00
|
|
|
def run(self, environment):
|
|
|
|
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'promote', 'enabled'):
|
2016-09-19 20:34:01 +02:00
|
|
|
return
|
2016-09-19 20:43:41 +02:00
|
|
|
if environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list').strip(" \t\n") == '':
|
|
|
|
return
|
2016-08-19 17:22:08 +02:00
|
|
|
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
2016-09-19 20:34:01 +02:00
|
|
|
return
|
2016-08-19 17:22:08 +02:00
|
|
|
if environment['screenData']['newDelta'] == '':
|
2016-09-19 20:34:01 +02:00
|
|
|
return
|
2016-08-19 17:22:08 +02:00
|
|
|
if int(time.time() - environment['input']['lastInputTime']) < environment['runtime']['settingsManager'].getSettingAsInt(environment, 'promote', 'inactiveTimeoutSec'):
|
2016-09-19 20:34:01 +02:00
|
|
|
return
|
2016-08-19 17:22:08 +02:00
|
|
|
if len(environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list')) == 0:
|
2016-09-19 20:34:01 +02:00
|
|
|
return
|
2016-08-19 17:22:08 +02:00
|
|
|
for promote in environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list').split(','):
|
|
|
|
if promote in environment['screenData']['newDelta']:
|
|
|
|
environment['runtime']['outputManager'].playSoundIcon(environment,'PromotedText')
|
|
|
|
environment['input']['lastInputTime'] = time.time()
|
2016-09-19 20:34:01 +02:00
|
|
|
return
|
2016-08-19 17:22:08 +02:00
|
|
|
|
|
|
|
def setCallback(self, callback):
|
|
|
|
pass
|
2016-09-02 21:37:36 +02:00
|
|
|
|