fix settings stuff

This commit is contained in:
chrys 2016-07-26 23:39:22 +02:00
parent d90ebb8932
commit f00621832e
3 changed files with 37 additions and 29 deletions

View File

@ -1,3 +1,4 @@
[sound] [sound]
enabled=False, enabled=False,
driver=sox driver=sox
@ -5,19 +6,23 @@ theme=default
[speech] [speech]
enabled=True enabled=True
driver=espeak #driver=espeak
rate=800 #language=en-us
#voice=en-us
driver=speechd
#rate=800
rate=50
volume=100
pitch=50 pitch=50
module=espeak module=espeak
voice=en-us voice=de
language=en-us language=de
volume=200
[braille] [braille]
enabled=False enabled=False
layout=en layout=en
[screen] ['screen]
driver=linux driver=linux
[keyboard] [keyboard]
@ -28,3 +33,4 @@ wordEcho=True
[general] [general]
debugLevel=0 debugLevel=0
punctuationLevel=1 punctuationLevel=1

View File

@ -6,7 +6,7 @@ class outputManager():
def presentText(self, environment, text, interrupt=True, soundIconName = ''): def presentText(self, environment, text, interrupt=True, soundIconName = ''):
self.speakText(environment, text, interrupt) self.speakText(environment, text, interrupt)
self.brailleText(environment, text) self.brailleText(environment, text)
self.playSoundIcon(environment, soundIconName): self.playSoundIcon(environment, soundIconName)
def speakText(self, environment, text, interrupt=True): def speakText(self, environment, text, interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'):
@ -33,16 +33,16 @@ class outputManager():
environment['runtime']['speechDriver'].cancel() environment['runtime']['speechDriver'].cancel()
environment['runtime']['soundDriver'].cancel() environment['runtime']['soundDriver'].cancel()
def playSoundIcon(self, environment, iconName, interrupt=True): def playSoundIcon(self, environment, soundIconName, interrupt=True):
if soundIconName == '': if soundIconName == '':
return return
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'):
return return
if environment['runtime']['soundDriver'] == None: if environment['runtime']['soundDriver'] == None:
return return
print(IconName) print(soundIconName)
try: try:
print(environment['soundIcons'][iconName]) print(environment['soundIcons'][soundIconName])
environment['runtime']['soundDriver'].playSoundFile(environment, environment['soundIcons'][iconName], interrupt) environment['runtime']['soundDriver'].playSoundFile(environment, environment['soundIcons'][soundIconName], interrupt)
except: except:
print('no icon there for' + IconName) print('no icon there for' + IconName)

View File

@ -1,6 +1,7 @@
#!/bin/python #!/bin/python
import evdev import evdev
import importlib.util import importlib.util
import os
from configparser import ConfigParser from configparser import ConfigParser
from core import inputManager from core import inputManager
from core import outputManager from core import outputManager
@ -89,7 +90,7 @@ class settingsManager():
FilePath = Values[1] FilePath = Values[1]
validKeyString = True validKeyString = True
else: else:
if os.path.exists(soundIconPath + Values[1]) if os.path.exists(soundIconPath + Values[1]):
FilePath = soundIconPath + Values[1] FilePath = soundIconPath + Values[1]
validSoundIcon = True validSoundIcon = True
if validSoundIcon: if validSoundIcon:
@ -99,6 +100,7 @@ class settingsManager():
def loadSettings(self, environment, settingConfigPath='../../config/settings/settings.conf'): def loadSettings(self, environment, settingConfigPath='../../config/settings/settings.conf'):
environment['settings'] = ConfigParser() environment['settings'] = ConfigParser()
#if not exist what is ?????
environment['settings'].read(settingConfigPath) environment['settings'].read(settingConfigPath)
return environment return environment
@ -164,29 +166,29 @@ class settingsManager():
def initFenrirConfig(self): def initFenrirConfig(self):
return self.reInitFenrirConfig(environment.environment) return self.reInitFenrirConfig(environment.environment)
def reInitFenrirConfig(self, environment, settingsRoot = '/etc/fenrir/'): def reInitFenrirConfig(self, environment, settingsRoot = '../../config/'):
environment['runtime']['settingsManager'] = self environment['runtime']['settingsManager'] = self
environment['runtime']['inputManager'] = inputManager.inputManager() environment['runtime']['inputManager'] = inputManager.inputManager()
environment['runtime']['outputManager'] = outputManager.outputManager() environment['runtime']['outputManager'] = outputManager.outputManager()
environment = environment['runtime']['settingsManager'].loadSettings(environment) environment = environment['runtime']['settingsManager'].loadSettings(environment)
if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if not os.path.exists(self.getSetting(environment, 'keyboard','keyboardLayout')):
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout')):
self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout'))
environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout'))
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf'):
self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf'):
environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout')) environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout'))
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout') + '.conf'):
self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout') + '.conf')
environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout'))
else: else:
environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout')) environment = environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout'))
if not os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'): if not os.path.exists(self.getSetting(environment, 'sound','theme') + '/soundicons.conf'):
if os.path.exists(settingsRoot + 'sound/'+ self.getSetting('sound','theme')): if os.path.exists(settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme')):
self.setSetting(environment, 'sound', 'theme', settingsRoot + 'sound/'+ self.getSetting('sound','theme')) self.setSetting(environment, 'sound', 'theme', settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme'))
if os.path.exists(settingsRoot + 'sound/'+ self.getSetting('sound','theme') + '/soundicons.conf'): if os.path.exists(settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme') + '/soundicons.conf'):
environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting('sound','theme')) environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme'))
else: else:
environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting('sound','theme')) environment = environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme'))
environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'] = commandManager.commandManager()
environment = environment['runtime']['commandManager'].loadCommands(environment,'commands') environment = environment['runtime']['commandManager'].loadCommands(environment,'commands')