From c837408b3f495cf294f5b8c11c5a77bb1945fa75 Mon Sep 17 00:00:00 2001 From: gotmor Date: Thu, 20 Dec 2007 03:07:25 +0000 Subject: new syntax for ^r() and ^ro() gcpubar and gdbar fixes git-svn-id: http://dzen.googlecode.com/svn/trunk@173 f2baff5b-bf2c-0410-a398-912abdc3d8b2 --- gadgets/gcpubar.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'gadgets/gcpubar.c') diff --git a/gadgets/gcpubar.c b/gadgets/gcpubar.c index a55b781..4349cbf 100644 --- a/gadgets/gcpubar.c +++ b/gadgets/gcpubar.c @@ -32,7 +32,7 @@ THE SOFTWARE. /* bar color for critical values */ #define CRITCOL "red" -static void pbar (double, int, int, int, int); +static void pbar (const char *, double, int, int, int, int); struct cpu_info { unsigned long long user; @@ -44,7 +44,7 @@ struct cpu_info { char *bg, *fg; static void -pbar(double perc, int maxc, int height, int print_nl, int mode) { +pbar(const char *label, double perc, int maxc, int height, int print_nl, int mode) { int i, rp; double l; @@ -58,13 +58,13 @@ pbar(double perc, int maxc, int height, int print_nl, int mode) { rp = (int)perc; if(mode) - printf("CPU: %3d%% ^ib(1)^fg(%s)^ro(%dx%d)^p(%d)^fg(%s)^r(%dx%d)^p(%d)^ib(0)^fg()%s", - rp, bg, maxc, height, -1*(maxc-1), + printf("%s %3d%% ^ib(1)^fg(%s)^ro(%dx%d)^p(%d)^fg(%s)^r(%dx%d)^p(%d)^ib(0)^fg()%s", + label ? label : "", rp, bg, maxc, height, -1*(maxc-1), (rp>=CPUCRIT) ? CRITCOL : fg, (int)l, height-2, (maxc-1)-(int)l, print_nl ? "\n" : ""); else - printf("CPU: %3d%% ^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)^fg()%s", - rp, (rp>=CPUCRIT) ? CRITCOL : fg, (int)l, height, - bg, maxc-(int)l, height, print_nl ? "\n" : ""); + printf("%s %3d%% ^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)^fg()%s", + label ? label : "", rp, (rp>=CPUCRIT) ? CRITCOL : fg, (int)l, + height, bg, maxc-(int)l, height, print_nl ? "\n" : ""); fflush(stdout); } @@ -81,6 +81,7 @@ main(int argc, char *argv[]) struct cpu_info mcpu; FILE *statfp; char buf[256], *ep; + const char *label = NULL; /* defaults */ int mode = 0; @@ -133,11 +134,15 @@ main(int argc, char *argv[]) strcpy(bg, "darkgrey"); } } + else if(!strncmp(argv[i], "-l", 3)) { + if(++i < argc) + label = argv[i]; + } else if(!strncmp(argv[i], "-nonl", 6)) { print_nl = 0; } else { - printf("usage: %s [-i ] [-c ] [-fg ] [-bg ] [-w ] [-h ] [-o] [-nonl]\n", argv[0]); + printf("usage: %s [-l