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

View File

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

View File

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