From 5454723d1fa8e06fa9fbb9523388776e596e86ae Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 22 Sep 2016 21:56:37 +0200 Subject: [PATCH] make onAppSwitch trigger initial working --- .../{command_template.py => test.py} | 7 ++-- .../onSwitchApplicationProfile/agetty.py | 33 +++++++++++++++++++ .../onSwitchApplicationProfile/bash.py | 33 +++++++++++++++++++ .../onSwitchApplicationProfile/default.py | 33 +++++++++++++++++++ .../onSwitchApplicationProfile/vim.py | 33 +++++++++++++++++++ src/fenrir-package/core/commandManager.py | 20 +++++------ src/fenrir-package/fenrir.py | 2 +- 7 files changed, 147 insertions(+), 14 deletions(-) rename src/fenrir-package/commands/onApplicationChange/{command_template.py => test.py} (69%) create mode 100644 src/fenrir-package/commands/onSwitchApplicationProfile/agetty.py create mode 100644 src/fenrir-package/commands/onSwitchApplicationProfile/bash.py create mode 100644 src/fenrir-package/commands/onSwitchApplicationProfile/default.py create mode 100644 src/fenrir-package/commands/onSwitchApplicationProfile/vim.py diff --git a/src/fenrir-package/commands/onApplicationChange/command_template.py b/src/fenrir-package/commands/onApplicationChange/test.py similarity index 69% rename from src/fenrir-package/commands/onApplicationChange/command_template.py rename to src/fenrir-package/commands/onApplicationChange/test.py index 422e89e8..ca4d74b6 100644 --- a/src/fenrir-package/commands/onApplicationChange/command_template.py +++ b/src/fenrir-package/commands/onApplicationChange/test.py @@ -16,9 +16,10 @@ class command(): def getDescription(self): return 'No description found' def run(self): - print('new %s', self.env['screenData']['newApplication']) - print('old %s', self.env['screenData']['oldApplication']) - print('-----------') + #print('new ', self.env['screenData']['newApplication']) + #print('old ', self.env['screenData']['oldApplication']) + #print('-----------') + pass def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onSwitchApplicationProfile/agetty.py b/src/fenrir-package/commands/onSwitchApplicationProfile/agetty.py new file mode 100644 index 00000000..6981dffb --- /dev/null +++ b/src/fenrir-package/commands/onSwitchApplicationProfile/agetty.py @@ -0,0 +1,33 @@ +#!/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 'No description found' + def load(self): + print('--------------') + print('agetty') + print('load old',self.env['screenData']['oldApplication']) + print('load new',self.env['screenData']['newApplication']) + print('--------------') + + def unload(self): + print('--------------') + print('agetty') + print('unload old',self.env['screenData']['oldApplication']) + print('unload new',self.env['screenData']['newApplication']) + print('--------------') + + def setCallback(self, callback): + pass diff --git a/src/fenrir-package/commands/onSwitchApplicationProfile/bash.py b/src/fenrir-package/commands/onSwitchApplicationProfile/bash.py new file mode 100644 index 00000000..3cd9d8d0 --- /dev/null +++ b/src/fenrir-package/commands/onSwitchApplicationProfile/bash.py @@ -0,0 +1,33 @@ +#!/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 'No description found' + def load(self): + print('--------------') + print('bash') + print('load old',self.env['screenData']['oldApplication']) + print('load new',self.env['screenData']['newApplication']) + print('--------------') + + def unload(self): + print('--------------') + print('bash') + print('unload old',self.env['screenData']['oldApplication']) + print('unload new',self.env['screenData']['newApplication']) + print('--------------') + + def setCallback(self, callback): + pass diff --git a/src/fenrir-package/commands/onSwitchApplicationProfile/default.py b/src/fenrir-package/commands/onSwitchApplicationProfile/default.py new file mode 100644 index 00000000..87326f4f --- /dev/null +++ b/src/fenrir-package/commands/onSwitchApplicationProfile/default.py @@ -0,0 +1,33 @@ +#!/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 'No description found' + def load(self): + print('--------------') + print('default') + print('load old',self.env['screenData']['oldApplication']) + print('load new',self.env['screenData']['newApplication']) + print('--------------') + + def unload(self): + print('--------------') + print('default') + print('unload old',self.env['screenData']['oldApplication']) + print('unload new',self.env['screenData']['newApplication']) + print('--------------') + + def setCallback(self, callback): + pass diff --git a/src/fenrir-package/commands/onSwitchApplicationProfile/vim.py b/src/fenrir-package/commands/onSwitchApplicationProfile/vim.py new file mode 100644 index 00000000..3f8563e4 --- /dev/null +++ b/src/fenrir-package/commands/onSwitchApplicationProfile/vim.py @@ -0,0 +1,33 @@ +#!/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 'No description found' + def load(self): + print('--------------') + print('vim') + print('load old',self.env['screenData']['oldApplication']) + print('load new',self.env['screenData']['newApplication']) + print('--------------') + + def unload(self): + print('--------------') + print('vim') + print('unload old',self.env['screenData']['oldApplication']) + print('unload new',self.env['screenData']['newApplication']) + print('--------------') + + def setCallback(self, callback): + pass diff --git a/src/fenrir-package/core/commandManager.py b/src/fenrir-package/core/commandManager.py index fcc43ca4..ad110ccc 100644 --- a/src/fenrir-package/core/commandManager.py +++ b/src/fenrir-package/core/commandManager.py @@ -67,16 +67,16 @@ class commandManager(): oldScript = '' if isinstance(unLoadScript, list): if len(unLoadScript) == 0: - oldScript = 'default' + oldScript = 'DEFAULT' else: - oldScript = unLoadScript[0] + oldScript = unLoadScript[0].upper() elif unLoadScript: - oldScript = str(unLoadScript) + oldScript = str(unLoadScript).upper() if oldScript == '': - oldScript == 'default' + oldScript == 'DEFAULT' if self.commandExists(oldScript, trigger): try: - self.env['commands'][trigger][oldScript].unload() + self.env['commands'][trigger][oldScript].unload() except Exception as e: print(e) self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + oldScript ,debug.debugLevel.ERROR) @@ -85,16 +85,16 @@ class commandManager(): newScript = '' if isinstance(loadScript, list): if len(loadScript) == 0: - newScript = 'default' + newScript = 'DEFAULT' else: - newScript = loadScript[0] + newScript = loadScript[0].upper() elif unLoadScript: - newScript = str(loadScript) + newScript = str(loadScript).upper() if newScript == '': - newScript == 'default' + newScript == 'DEFAULT' if self.commandExists(newScript, trigger): try: - self.env['commands'][trigger][newScript].load() + self.env['commands'][trigger][newScript].load() except Exception as e: print(e) self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + newScript ,debug.debugLevel.ERROR) diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index f6acd94c..a2d14486 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -52,7 +52,7 @@ class fenrir(): if self.environment['screenData']['newApplication'] != self.environment['screenData']['oldApplication']: self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') - self.environment['runtime']['commandManager'].executeSwitchTrigger(self, 'onSwitchApplicationProfile', \ + self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \ self.environment['screenData']['oldApplication'], self.environment['screenData']['newApplication']) self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') if self.environment['screenData']['newTTY'] == self.environment['screenData']['oldTTY']: