mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 12:28:10 +01:00
updated the example with the latest library.
This commit is contained in:
@@ -38,8 +38,6 @@ import os
|
||||
|
||||
import wmdocklib
|
||||
|
||||
from wmdocklib import char_width, char_height
|
||||
|
||||
width = 64
|
||||
height = 64
|
||||
|
||||
@@ -282,41 +280,98 @@ def parseCommandLine(argv):
|
||||
sys.exit(2)
|
||||
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):
|
||||
sys.stderr.write(
|
||||
"Can't read the RGB file, try setting it differently using -r,\n")
|
||||
sys.stderr.write(
|
||||
"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'),
|
||||
('background', 'background'),
|
||||
('graphforeground', 'vgraph'),
|
||||
('graphbackground', 'vgraphbg'))
|
||||
for key, value in colors:
|
||||
col = config.get(key)
|
||||
if not col is None:
|
||||
code = wmdocklib.getColorCode(col, rgbFileName)
|
||||
if code is None:
|
||||
sys.stderr.write('Bad colorcode for %s, ignoring.\n' % key)
|
||||
else:
|
||||
wmdocklib.setColor(xpm, value, code)
|
||||
|
||||
|
||||
palette = {
|
||||
' ': '#208120812081',
|
||||
'.': '#00000000FFFF',
|
||||
'o': '#C71BC30BC71B',
|
||||
'O': '#861782078E38',
|
||||
'+': '#EFBEF3CEEFBE',
|
||||
'@': '#618561856185',
|
||||
'#': '#9E79A2899E79',
|
||||
'$': '#410341034103',
|
||||
'o': '#2020b2b2aaaa',
|
||||
'/': '#2020b2b2aaaa',
|
||||
'-': '#707070707070',
|
||||
'|': '#2020b2b2aaaa',
|
||||
'I': '#707070707070',
|
||||
'_': '#000000000000',
|
||||
'%': '#2081B2CAAEBA',
|
||||
}
|
||||
background = \
|
||||
[' ...............................................................................................',
|
||||
' .///..___..ooo..___..___......|.I..............................................................',
|
||||
' .///..___..ooo..___..___......|.I..............................................................',
|
||||
' .///..___..ooo..___..___......|.I..............................................................',
|
||||
' .///..___..___..___..___......|.I..............................................................',
|
||||
' .///..___..___..___..___......|.I..............................................................',
|
||||
' .///..___..___..___..___......|.I..............................................................',
|
||||
' .///..___..___..ooo..___......|.I..............................................................',
|
||||
' .///..___..___..ooo..___......|.I..............................................................',
|
||||
' .///..___..___..ooo..___......|.I..............................................................',
|
||||
' .///..___..___..___..___......|.I..............................................................',
|
||||
' .///..___..___..___..___......|.I..............................................................',
|
||||
' .///..___..___..___..___......|.I..............................................................',
|
||||
' .///..___..___..___..ooo......|.I..............................................................',
|
||||
' .///..___..___..___..ooo......|.I..............................................................',
|
||||
' .///..___..___..___..ooo......|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///..........................|.I..............................................................',
|
||||
' .///...........................................................................................',
|
||||
' .///...-------------------------------------------------------------------------------------...',
|
||||
' .///...-------------------------------------------------------------------------------------...',
|
||||
' .///...-------------------------------------------------------------------------------------...',
|
||||
' .///...-------------------------------------------------------------------------------------...',
|
||||
' .///...........................................................................................',
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ...............................................................................................',
|
||||
' ...............................................................................................',
|
||||
]
|
||||
|
||||
def main():
|
||||
global char_width, char_height
|
||||
char_width, char_height = wmdocklib.initPixmap(background,
|
||||
font_name='6x8',
|
||||
palette=palette)
|
||||
config = parseCommandLine(sys.argv)
|
||||
parseColors(defaultRGBFiles, config, xpm)
|
||||
procStat = config.get('procstat', defaultProcStat)
|
||||
if not os.access(procStat, os.R_OK):
|
||||
sys.stderr.write(
|
||||
@@ -334,95 +389,11 @@ def main():
|
||||
except IndexError:
|
||||
programName = ''
|
||||
sys.argv[0] = programName
|
||||
wmdocklib.setDefaultPixmap(xpm)
|
||||
wmdocklib.openXwindow(sys.argv, width, height)
|
||||
pywmsysmon = PywmSysMon(procMeminfo, procStat, ignoreNice, updateDelay)
|
||||
pywmsysmon.mainLoop()
|
||||
|
||||
|
||||
xpm = \
|
||||
['160 100 15 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 #2020b2b2aaaa s vgraph',
|
||||
'I\tc #707070707070 s vgraphbg',
|
||||
'_\tc #000000000000 s background',
|
||||
'%\tc #2081B2CAAEBA s text',
|
||||
' ...............................................................................................',
|
||||
' .///..___..ooo..___..___......|.I..............................................................',
|
||||
' .///..___..ooo..___..___......|.I..............................................................',
|
||||
' .///..___..ooo..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..ooo..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..ooo..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..ooo..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..___......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..ooo......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..ooo......|.I..............................................................',
|
||||
' ________________________________________________________ .///..___..___..___..ooo......|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///..........................|.I..............................................................',
|
||||
' ________________________________________________________ .///...........................................................................................',
|
||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
||||
' ________________________________________________________ .///...-------------------------------------------------------------------------------------...',
|
||||
' ________________________________________________________ .///...........................................................................................',
|
||||
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' .///////////////////////////////////////////////////////////////////////////////////////////...',
|
||||
' ...............................................................................................',
|
||||
' ...............................................................................................',
|
||||
] + wmdocklib.char_map
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user