mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 12:28:10 +01:00
updated and (more or less) tested.
This commit is contained in:
@@ -42,8 +42,6 @@ import popen2
|
|||||||
|
|
||||||
import wmdocklib
|
import wmdocklib
|
||||||
|
|
||||||
from wmdocklib import char_width, char_height
|
|
||||||
|
|
||||||
prevStat = {'user':0,
|
prevStat = {'user':0,
|
||||||
'nice':0,
|
'nice':0,
|
||||||
'sys':0,
|
'sys':0,
|
||||||
@@ -113,6 +111,9 @@ class UserMethods:
|
|||||||
f.close()
|
f.close()
|
||||||
return lambda: 'sys: %s' % temp
|
return lambda: 'sys: %s' % temp
|
||||||
|
|
||||||
|
def ls(self):
|
||||||
|
return lambda: 'boh'
|
||||||
|
|
||||||
def showDnWithoutDescs(self, entry):
|
def showDnWithoutDescs(self, entry):
|
||||||
"""Strip descriptions from some text where the descs are indented.
|
"""Strip descriptions from some text where the descs are indented.
|
||||||
|
|
||||||
@@ -372,15 +373,12 @@ class Entry:
|
|||||||
Or nothing if we can't come up with something good. Could be nice to
|
Or nothing if we can't come up with something good. Could be nice to
|
||||||
extend this function with chars more fitting for your language.
|
extend this function with chars more fitting for your language.
|
||||||
"""
|
"""
|
||||||
fromChars = 'áéíóúàèìòùâêîôûäëïöü'
|
fromChars = u'ñźńśćżłáéíóúàèìòùâêîôûäëïöüãẽĩõũ'
|
||||||
toChars = 'aeiouaeiouaeiouaeiou'
|
toChars = u'nznsczlaeiouaeiouaeiouaeiouaeiou'
|
||||||
deleteChars = []
|
for frm, to in zip(fromChars, toChars):
|
||||||
for c in text.lower():
|
text = text.replace(frm, to)
|
||||||
if not (c in letters or c in digits or c in fromChars):
|
text = text.replace(frm.upper(), to.upper())
|
||||||
deleteChars.append(c)
|
text = ''.join([i for i in text if 32 <= ord(i) < 128])
|
||||||
deleteChars = ''.join(deleteChars)
|
|
||||||
trans = string.maketrans(fromChars, toChars)
|
|
||||||
text = string.translate(text.lower(), trans, deleteChars)
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def getAllText(self):
|
def getAllText(self):
|
||||||
@@ -541,35 +539,6 @@ def parseCommandLine(argv):
|
|||||||
d['configfile'] = a
|
d['configfile'] = a
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def parseColors(defaultRGBFileList, config, xpm):
|
|
||||||
rgbFileName = ''
|
|
||||||
for fn in defaultRGBFileList:
|
|
||||||
if os.access(fn, os.R_OK):
|
|
||||||
rgbFileName = fn
|
|
||||||
break
|
|
||||||
rgbFileName = config.get('rgbfile', rgbFileName)
|
|
||||||
useColors = 1
|
|
||||||
if not os.access(rgbFileName, os.R_OK):
|
|
||||||
err(
|
|
||||||
"Can't read the RGB file, try setting it differently using -r,\n")
|
|
||||||
err(
|
|
||||||
"Ignoring your color settings, using the defaults.\n")
|
|
||||||
useColors = 0
|
|
||||||
if useColors:
|
|
||||||
# Colors is a list with (<config_key>, <xpm-key>) pairs.
|
|
||||||
colors = (('barfgcolor', 'graph'),
|
|
||||||
('barbgcolor', 'graphbg'),
|
|
||||||
('textcolor', 'text'),
|
|
||||||
('background', 'background'))
|
|
||||||
for key, value in colors:
|
|
||||||
col = config.get(key)
|
|
||||||
if not col is None:
|
|
||||||
code = wmdocklib.getColorCode(col, rgbFileName)
|
|
||||||
if code is None:
|
|
||||||
err('Bad colorcode for %s, ignoring.\n' % key)
|
|
||||||
else:
|
|
||||||
wmdocklib.setColor(xpm, value, code)
|
|
||||||
|
|
||||||
def readConfigFile(fileName):
|
def readConfigFile(fileName):
|
||||||
"""Read the config file.
|
"""Read the config file.
|
||||||
|
|
||||||
@@ -595,105 +564,113 @@ def readConfigFile(fileName):
|
|||||||
l[i][o] = cp.get(strI, o, raw=1)
|
l[i][o] = cp.get(strI, o, raw=1)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
background = \
|
||||||
|
[
|
||||||
|
' ...............................................................................................',
|
||||||
|
' .///..___..ooo..___..___.......................................................................',
|
||||||
|
' .///..___..ooo..___..___.......................................................................',
|
||||||
|
' .///..___..ooo..___..___.......................................................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///.._________________________________________________________................................',
|
||||||
|
' .///..___..___..___..___.......................................................................',
|
||||||
|
' .///..___..___..___..ooo.......................................................................',
|
||||||
|
' .///..___..___..___..ooo.......................................................................',
|
||||||
|
' .///..___..___..___..ooo.......................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///...-------------------------------------------------------------------------------------...',
|
||||||
|
' .///...-------------------------------------------------------------------------------------...',
|
||||||
|
' .///...-------------------------------------------------------------------------------------...',
|
||||||
|
' .///...-------------------------------------------------------------------------------------...',
|
||||||
|
' .///...........................................................................................',
|
||||||
|
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||||
|
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||||
|
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||||
|
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||||
|
' ...............................................................................................',
|
||||||
|
' ...............................................................................................',
|
||||||
|
]
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
clConfig = parseCommandLine(sys.argv)
|
clConfig = parseCommandLine(sys.argv)
|
||||||
|
|
||||||
|
palette = {
|
||||||
|
' ': '#208120812081',
|
||||||
|
'.': '#00000000FFFF',
|
||||||
|
'o': '#C71BC30BC71B',
|
||||||
|
'O': '#861782078E38',
|
||||||
|
'+': '#EFBEF3CEEFBE',
|
||||||
|
'@': '#618561856185',
|
||||||
|
'#': '#9E79A2899E79',
|
||||||
|
'$': '#410341034103',
|
||||||
|
}
|
||||||
|
palette['o'] = clConfig.get('indicator', '#2020b2b2aaaa')
|
||||||
|
palette['/'] = clConfig.get('graph', '#2020b2b2aaaa')
|
||||||
|
palette['-'] = clConfig.get('graphbg', '#707070707070')
|
||||||
|
palette['_'] = clConfig.get('background', '#000000000000')
|
||||||
|
palette['%'] = clConfig.get('text', '#2081B2CAAEBA')
|
||||||
|
|
||||||
configFile = clConfig.get('configfile', defaultConfigFile)
|
configFile = clConfig.get('configfile', defaultConfigFile)
|
||||||
if not configFile.count(os.sep):
|
if not configFile.count(os.sep):
|
||||||
configFile = os.sep.join(sys.argv[0].split(os.sep)[:-1]) + os.sep + configFile
|
configFile = os.sep.join(sys.argv[0].split(os.sep)[:-1]) + os.sep + configFile
|
||||||
configFile = os.path.expanduser(configFile)
|
configFile = os.path.expanduser(configFile)
|
||||||
config = readConfigFile(configFile)
|
config = readConfigFile(configFile)
|
||||||
parseColors(defaultRGBFiles, clConfig, xpm)
|
|
||||||
try:
|
try:
|
||||||
programName = sys.argv[0].split(os.sep)[-1]
|
programName = sys.argv[0].split(os.sep)[-1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
programName = ''
|
programName = ''
|
||||||
sys.argv[0] = programName
|
sys.argv[0] = programName
|
||||||
wmdocklib.setDefaultPixmap(xpm)
|
|
||||||
|
global char_width, char_height
|
||||||
|
char_width, char_height = wmdocklib.initPixmap(background,
|
||||||
|
font_name='8x8',
|
||||||
|
bg='f', fg='9',
|
||||||
|
palette=palette)
|
||||||
|
|
||||||
wmdocklib.openXwindow(sys.argv, width, height)
|
wmdocklib.openXwindow(sys.argv, width, height)
|
||||||
pywmgeneric = PywmGeneric(config)
|
pywmgeneric = PywmGeneric(config)
|
||||||
pywmgeneric.mainLoop()
|
pywmgeneric.mainLoop()
|
||||||
|
|
||||||
xpm = \
|
|
||||||
['160 100 13 1',
|
|
||||||
' \tc #208120812081',
|
|
||||||
'.\tc #00000000FFFF',
|
|
||||||
'o\tc #C71BC30BC71B',
|
|
||||||
'O\tc #861782078E38',
|
|
||||||
'+\tc #EFBEF3CEEFBE',
|
|
||||||
'@\tc #618561856185',
|
|
||||||
'#\tc #9E79A2899E79',
|
|
||||||
'$\tc #410341034103',
|
|
||||||
'o\tc #2020b2b2aaaa s indicator',
|
|
||||||
'/\tc #2020b2b2aaaa s graph',
|
|
||||||
'-\tc #707070707070 s graphbg',
|
|
||||||
'_\tc #000000000000 s background',
|
|
||||||
'%\tc #2081B2CAAEBA s text',
|
|
||||||
' ...............................................................................................',
|
|
||||||
' .///..___..ooo..___..___.......................................................................',
|
|
||||||
' .///..___..ooo..___..___.......................................................................',
|
|
||||||
' .///..___..ooo..___..___.......................................................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///.._________________________________________________________................................',
|
|
||||||
' ________________________________________________________ .///..___..___..___..___.......................................................................',
|
|
||||||
' ________________________________________________________ .///..___..___..___..ooo.......................................................................',
|
|
||||||
' ________________________________________________________ .///..___..___..___..ooo.......................................................................',
|
|
||||||
' ________________________________________________________ .///..___..___..___..ooo.......................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
|
||||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
|
||||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
|
||||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
|
||||||
' ________________________________________________________ .///...........................................................................................',
|
|
||||||
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
|
|
||||||
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
|
|
||||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
|
||||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
|
||||||
' ...............................................................................................',
|
|
||||||
' ...............................................................................................',
|
|
||||||
] + wmdocklib.char_map
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user