diff --git a/examples/pywmseti.py b/examples/pywmseti.py index b5ab921..a490baf 100755 --- a/examples/pywmseti.py +++ b/examples/pywmseti.py @@ -39,8 +39,6 @@ import os import wmdocklib -from wmdocklib import char_width, char_height - width = 64 height = 64 @@ -370,6 +368,89 @@ def parseColors(defaultRGBFileNames, config, xpm): else: wmdocklib.setColor(xpm, value, code) +palette = { + ' ': '#208120812081', + '.': '#00000000FFFF', + 'o': '#C71BC30BC71B', + 'O': '#861782078E38', + '+': '#EFBEF3CEEFBE', + '@': '#618561856185', + '#': '#9E79A2899E79', + '$': '#410341034103', + 'o': '#2020b2b2aaaa', + '/': '#2020b2b2aaaa', + '-': '#707070707070', + '_': '#000000000000', + '%': '#2081B2CAAEBA', +} + +background = \ +[' ...............................................................................................', + ' .///..___..ooo..___..___.......................................................................', + ' .///..___..ooo..___..___.......................................................................', + ' .///..___..ooo..___..___.......................................................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..ooo..___.......................................................................', + ' .///..___..___..ooo..___.......................................................................', + ' .///..___..___..ooo..___.......................................................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..___..___.......................................................................', + ' .///..___..___..___..ooo.......................................................................', + ' .///..___..___..___..ooo.......................................................................', + ' .///..___..___..___..ooo.......................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...........................................................................................', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...-------------------------------------------------------------------------------------...', + ' .///...........................................................................................', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' .///////////////////////////////////////////////////////////////////////////////////////////...', + ' ...............................................................................................', + ' ...............................................................................................', + ] + def main(): clConfig = parseCommandLine(sys.argv) configFile = clConfig.get('configfile', defaultConfigFile) @@ -381,7 +462,6 @@ def main(): for i in clConfig.iteritems(): config[i[0]] = i[1] # Get the configurations - parseColors(defaultRGBFiles, config, xpm) setiDir = config.get('setidir') if setiDir is None: sys.stderr.write( @@ -409,94 +489,14 @@ def main(): except IndexError: programName = '' sys.argv[0] = programName - wmdocklib.setDefaultPixmap(xpm) + wmdocklib.initPixmap(background, + palette=palette) wmdocklib.openXwindow(sys.argv, width, height) wmdocklib.addMouseRegion(0, xOffset, yOffset, width - 2 * xOffset, height - 2 * yOffset) pwms = PywmSeti(statePath, uinfoPath, pidPath, execCmd) pwms.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..___.......................................................................', - ' ________________________________________________________ .///..___..___..___..___.......................................................................', - ' ________________________________________________________ .///..___..___..___..___.......................................................................', - ' ________________________________________________________ .///..___..___..___..___.......................................................................', - ' ________________________________________________________ .///..___..___..___..ooo.......................................................................', - ' ________________________________________________________ .///..___..___..___..ooo.......................................................................', - ' ________________________________________________________ .///..___..___..___..ooo.......................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...-------------------------------------------------------------------------------------...', - ' ________________________________________________________ .///...........................................................................................', - ' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...', - ' ________________________________________________________ .///////////////////////////////////////////////////////////////////////////////////////////...', - ' .///////////////////////////////////////////////////////////////////////////////////////////...', - ' .///////////////////////////////////////////////////////////////////////////////////////////...', - ' ...............................................................................................', - ' ...............................................................................................', - ] + wmdocklib.char_map - if __name__ == '__main__': main() diff --git a/examples/pywmsysmon.py b/examples/pywmsysmon.py index 67ec969..4093836 100755 --- a/examples/pywmsysmon.py +++ b/examples/pywmsysmon.py @@ -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 (, ) 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()