From 8ba334942e6d28505dbe256e231d562b279f0998 Mon Sep 17 00:00:00 2001 From: gotmor Date: Sat, 18 Aug 2007 00:42:39 +0000 Subject: conky style progressmeters for gdbar and gcpubar git-svn-id: http://dzen.googlecode.com/svn/trunk@158 f2baff5b-bf2c-0410-a398-912abdc3d8b2 --- gadgets/gcpubar.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'gadgets/gcpubar.c') 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; } } -- cgit v1.2.3-54-g00ecf