From e6a7733799d32bb6bf719ee34beb5b01d9db68ad Mon Sep 17 00:00:00 2001 From: gotmor Date: Sat, 4 Aug 2007 13:04:19 +0000 Subject: ready for release 0.8.0 new in-text commands: ^fg() and ^bg() without arguments set default colors ^ro() and ^co() outlined rectangle/circle fixes to gcpubar and gdbar to use ^fg() git-svn-id: http://dzen.googlecode.com/svn/trunk@151 f2baff5b-bf2c-0410-a398-912abdc3d8b2 --- gadgets/README.gcpubar | 7 ++++++- gadgets/gcpubar.c | 25 ++++++++++++++----------- gadgets/gdbar.c | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) (limited to 'gadgets') diff --git a/gadgets/README.gcpubar b/gadgets/README.gcpubar index e8f86aa..ec548cc 100644 --- a/gadgets/README.gcpubar +++ b/gadgets/README.gcpubar @@ -15,7 +15,7 @@ Command line options: less than 1 for intervals shorter than a second - -c : Terminate after diplaying (default: infite) + -c : Terminate after diplaying (default: infinite) argument to '-c' values -w : Width of the meter in pixels (default: 100) @@ -26,4 +26,9 @@ Command line options: -bg : Meter background color (default: darkgrey) + -nonl: no new line, don't put + '\n' at the end of the bar (default: do print '\n') + + + diff --git a/gadgets/gcpubar.c b/gadgets/gcpubar.c index f65569c..ea96d1a 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); +static void pbar (double, 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) { +pbar(double perc, int maxc, int height, int print_nl) { int i, rp; double l; @@ -57,9 +57,9 @@ pbar(double perc, int maxc, int height) { else rp = (int)perc; - printf("CPU: %3d%% ^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)\n", rp, + 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); + bg, maxc-(int)l, height, print_nl ? "\n" : ""); fflush(stdout); } @@ -74,11 +74,11 @@ main(int argc, char *argv[]) char buf[256], *ep; /* defaults */ - double ival=1.0; - int counts = 0; - int barwidth=100; - int barheight=10; - char *myfont = NULL; + double ival = 1.0; + int counts = 0; + int barwidth = 100; + int barheight = 10; + int print_nl = 1; for(i=1; i < argc; i++) { if(!strncmp(argv[i], "-i", 3)) { @@ -120,8 +120,11 @@ main(int argc, char *argv[]) strcpy(bg, "darkgrey"); } } + else if(!strncmp(argv[i], "-nonl", 6)) { + print_nl = 0; + } else { - printf("usage: %s [-i ] [-c ] [-fg ] [-bg ] [-w ] [-h ]\n", argv[0]); + printf("usage: %s [-i ] [-c ] [-fg ] [-bg ] [-w ] [-h ] [-nonl]\n", argv[0]); return EXIT_FAILURE; } } @@ -163,7 +166,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); + pbar(myload, barwidth, barheight, print_nl); ocpu = ncpu; } } diff --git a/gadgets/gdbar.c b/gadgets/gdbar.c index 4138770..af25632 100644 --- a/gadgets/gdbar.c +++ b/gadgets/gdbar.c @@ -51,7 +51,7 @@ pbar(const char* label, double perc, int maxc, int height, int pnl) { else rp = (int)perc; - printf("%s %3d%% ^fg(%s)^r(%dx%d)^fg(%s)^r(%dx%d)%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, -- cgit v1.2.3-54-g00ecf