diff options
author | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-08-18 00:42:39 +0000 |
---|---|---|
committer | gotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2> | 2007-08-18 00:42:39 +0000 |
commit | 8ba334942e6d28505dbe256e231d562b279f0998 (patch) | |
tree | 7ee0924724170619f3c18b4b330c72b1d7a14b9e /gadgets/gcpubar.c | |
parent | f2454aab13a7c08b11ab67f53201fc17802c6bf8 (diff) | |
download | dzen-8ba334942e6d28505dbe256e231d562b279f0998.tar.gz dzen-8ba334942e6d28505dbe256e231d562b279f0998.zip |
conky style progressmeters for gdbar and gcpubar
git-svn-id: http://dzen.googlecode.com/svn/trunk@158 f2baff5b-bf2c-0410-a398-912abdc3d8b2
Diffstat (limited to 'gadgets/gcpubar.c')
-rw-r--r-- | gadgets/gcpubar.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gadgets/gcpubar.c b/gadgets/gcpubar.c index ea96d1a..7d52b69 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); +static void pbar (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) { +pbar(double perc, int maxc, int height, int print_nl, int mode) { int i, rp; double l; @@ -57,9 +57,14 @@ pbar(double perc, int maxc, int height, int print_nl) { else rp = (int)perc; - 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" : ""); + if(mode) + printf("CPU: %3d%% ^ib(1)^fg(%s)^ro(%dx%d)^p(%d)^fg(%s)^r(%dx%d)^fg()%s", + rp, bg, maxc, height, -1*(maxc-1), + (rp>=CPUCRIT) ? CRITCOL : fg, (int)l-2, height-2, 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" : ""); fflush(stdout); } @@ -74,6 +79,7 @@ main(int argc, char *argv[]) char buf[256], *ep; /* defaults */ + int mode = 0; double ival = 1.0; int counts = 0; int barwidth = 100; @@ -92,6 +98,9 @@ main(int argc, char *argv[]) i++; } } + else if(!strncmp(argv[i], "-o", 3)) { + mode = 1; + } else if(!strncmp(argv[i], "-c", 3)) { if(++i < argc) counts = atoi(argv[i]); @@ -166,7 +175,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); + pbar(myload, barwidth, barheight, print_nl, mode); ocpu = ncpu; } } |