Update settingsManager.py
This commit is contained in:
parent
19bb08156c
commit
0498369601
@ -1,5 +1,70 @@
|
||||
#!/bin/python
|
||||
from configparser import ConfigParser
|
||||
import settings.settings
|
||||
|
||||
class settingsManager():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.kb'):
|
||||
kbConfig = open(kbConfigPath,"r")
|
||||
while(True):
|
||||
line = kbConfig.readline()
|
||||
if not line:
|
||||
break
|
||||
line = line.replace('\n','')
|
||||
if line.replace(" ","").startswith("#"):
|
||||
continue
|
||||
if line.count("=") != 1:
|
||||
continue
|
||||
sepLine = line.split('=')
|
||||
commandString = sepLine[1]
|
||||
keys = sepLine[0].replace(" ","").split(',')
|
||||
currShortcut = []
|
||||
validKeyString = True
|
||||
for key in keys:
|
||||
if len(key) < 3:
|
||||
validKeyString = False
|
||||
break
|
||||
if not key[0] in ['0','1','2']:
|
||||
validKeyString = False
|
||||
break
|
||||
if key[1] != '-':
|
||||
validKeyString = False
|
||||
break
|
||||
if key[2:] != '':
|
||||
keyInt = self.getCodeForKeyID(key[2:])
|
||||
else:
|
||||
validKeyString = False
|
||||
break
|
||||
if keyInt == 0:
|
||||
validKeyString = False
|
||||
break
|
||||
if not validKeyString:
|
||||
break
|
||||
else:
|
||||
currShortcut.append(key[0] + '-' + str(keyInt))
|
||||
if validKeyString:
|
||||
keyString = ''
|
||||
for k in sorted(currShortcut):
|
||||
if keyString != '':
|
||||
keyString += ','
|
||||
keyString += k
|
||||
environment['bindings'][keyString] = commandString
|
||||
kbConfig.close()
|
||||
return environment
|
||||
|
||||
def getCodeForKeyID(self, keyID):
|
||||
try:
|
||||
return evdev.ecodes.ecodes[keyID.upper()]
|
||||
except:
|
||||
return 0
|
||||
|
||||
def loadSettings(self, environment, settingConfigPath='../../config/settings/settings.cfg'):
|
||||
environment['settings'] = ConfigParser()
|
||||
environment['settings'].read(settingConfigPath)
|
||||
return environment
|
||||
|
||||
def getSetting(self, environment, setting):
|
||||
value = True # do be implemented
|
||||
return value
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user