diff options
author | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-12-20 03:07:25 +0000 |
---|---|---|
committer | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-12-20 03:07:25 +0000 |
commit | c837408b3f495cf294f5b8c11c5a77bb1945fa75 (patch) | |
tree | 273f6c0581949cc8dab75770c4401e39425d31b4 /gadgets | |
parent | 3e10817e2c4cae7038d738e4cd5d00074efb59a3 (diff) | |
download | dzen-c837408b3f495cf294f5b8c11c5a77bb1945fa75.tar.gz dzen-c837408b3f495cf294f5b8c11c5a77bb1945fa75.zip |
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
Diffstat (limited to 'gadgets')
-rw-r--r-- | gadgets/gcpubar.c | 23 | ||||
-rw-r--r-- | gadgets/gdbar.c | 4 |
2 files changed, 16 insertions, 11 deletions
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 <interval>] [-c <count>] [-fg <color>] [-bg <color>] [-w <pixel>] [-h <pixel>] [-o] [-nonl]\n", argv[0]); + printf("usage: %s [-l <label>] [-i <interval>] [-c <count>] [-fg <color>] [-bg <color>] [-w <pixel>] [-h <pixel>] [-o] [-nonl]\n", argv[0]); return EXIT_FAILURE; } } @@ -179,7 +184,7 @@ main(int argc, char *argv[]) total = (mcpu.user + mcpu.sys + mcpu.idle + mcpu.iowait) / 100.0; myload = (mcpu.user + mcpu.sys + mcpu.iowait) / total; - pbar(myload, barwidth, barheight, print_nl, mode); + pbar(label, myload, barwidth, barheight, print_nl, mode); ocpu = ncpu; } } diff --git a/gadgets/gdbar.c b/gadgets/gdbar.c index f905542..89cd7ec 100644 --- a/gadgets/gdbar.c +++ b/gadgets/gdbar.c @@ -52,13 +52,13 @@ pbar(const char* label, double perc, int maxc, int height, int pnl, int mode) { rp = (int)perc; if(mode) - printf("%s %3d%% ^ib(1)^fg(%s)^ro(%dx%d)^p(%d)^fg(%s)^r(%dx%d)^p(%d)^ib(0)^fg()%s", + 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, (int)maxc, height, -1*(maxc-1), fg, (int)l, height-2, maxc-(int)l-1, pnl ? "\n" : ""); else - printf("%s %3d%% ^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)^fg()%s", + printf("%s%3d%% ^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)^fg()%s", label ? label : "", rp, fg, (int)l, height, bg, maxc-(int)l, height, |