aboutsummaryrefslogtreecommitdiffstats
path: root/gadgets
diff options
context:
space:
mode:
authorgotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2007-08-04 13:04:19 +0000
committergotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2007-08-04 13:04:19 +0000
commite6a7733799d32bb6bf719ee34beb5b01d9db68ad (patch)
treec10481b0cbc717e3e5768d5ad2dff0c88d79768b /gadgets
parent63a6038c331449d728f090da9cf09de0c7a5124f (diff)
downloaddzen-e6a7733799d32bb6bf719ee34beb5b01d9db68ad.tar.gz
dzen-e6a7733799d32bb6bf719ee34beb5b01d9db68ad.zip
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
Diffstat (limited to 'gadgets')
-rw-r--r--gadgets/README.gcpubar7
-rw-r--r--gadgets/gcpubar.c25
-rw-r--r--gadgets/gdbar.c2
3 files changed, 21 insertions, 13 deletions
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 <interval>] [-c <count>] [-fg <color>] [-bg <color>] [-w <pixel>] [-h <pixel>]\n", argv[0]);
+ printf("usage: %s [-i <interval>] [-c <count>] [-fg <color>] [-bg <color>] [-w <pixel>] [-h <pixel>] [-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,