1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 10:35:10 +00:00

Special default & gauge fixes.

This commit is contained in:
Brenden Matthews 2009-04-09 20:10:08 -06:00
parent acfef7760f
commit 506f6ecc3b
6 changed files with 126 additions and 84 deletions

67
README
View File

@ -1642,6 +1642,7 @@ conky(1) conky(1)
tab (width, (start))
Puts a tab of the specified width, starting from column 'start'.
The unit is pixels for both arguments.
tail logfile lines (interval)
@ -1651,14 +1652,14 @@ conky(1) conky(1)
templateN (arg1) (arg2) (arg3 ...)
Evaluate the content of the templateN configuration variable
Evaluate the content of the templateN configuration variable
(where N is a value between 0 and 9, inclusively), applying sub
stitutions as described in the documentation of the correspond
ing configuration variable. The number of arguments is option
al, but must match the highest referred index in the template.
You can use the same special sequences in each argument as the
ones valid for a template definition, e.g. to allow an argument
to contain a whitespace. Also simple nesting of templates is
stitutions as described in the documentation of the correspond
ing configuration variable. The number of arguments is option
al, but must match the highest referred index in the template.
You can use the same special sequences in each argument as the
ones valid for a template definition, e.g. to allow an argument
to contain a whitespace. Also simple nesting of templates is
possible this way.
Here are some examples of template definitions:
@ -1667,7 +1668,7 @@ conky(1) conky(1)
template1 \1: ${fs_used \2} / ${fs_size \2}
template2 \1 \2
The following list shows sample usage of the templates defined
The following list shows sample usage of the templates defined
above, with the equivalent syntax when not using any template at
all:
@ -1680,7 +1681,7 @@ conky(1) conky(1)
time (format)
Local time, see man strftime to get more information about for
Local time, see man strftime to get more information about for
mat
@ -1689,23 +1690,23 @@ conky(1) conky(1)
tztime (timezone) (format)
Local time for specified timezone, see man strftime to get more
information about format. The timezone argument is specified in
similar fashion as TZ environment variable. For hints, look in
Local time for specified timezone, see man strftime to get more
information about format. The timezone argument is specified in
similar fashion as TZ environment variable. For hints, look in
/usr/share/zoneinfo. e.g. US/Pacific, Europe/Zurich, etc.
totaldown net
Total download, overflows at 4 GB on Linux with 32-bit arch and
Total download, overflows at 4 GB on Linux with 32-bit arch and
there doesn't seem to be a way to know how many times it has al
ready done that before conky has started.
top type, num
This takes arguments in the form:top (name) (number) Basically,
processes are ranked from highest to lowest in terms of cpu us
age, which is what (num) represents. The types are: "name",
"pid", "cpu", "mem", "mem_res", "mem_vsize", and "time". There
This takes arguments in the form:top (name) (number) Basically,
processes are ranked from highest to lowest in terms of cpu us
age, which is what (num) represents. The types are: "name",
"pid", "cpu", "mem", "mem_res", "mem_vsize", and "time". There
can be a max of 10 processes listed.
@ -1714,7 +1715,7 @@ conky(1) conky(1)
top_time type, num
Same as top, except sorted by total CPU time instead of current
Same as top, except sorted by total CPU time instead of current
CPU usage
@ -1736,9 +1737,9 @@ conky(1) conky(1)
upspeedgraph ("normal"|"log") (height),(width) (gradient colour 1)
(gradient colour 2) (scale) (net)
Upload speed graph, colours defined in hex, minus the #. If
scale is non-zero, it becomes the scale for the graph. Uses a
logarithmic scale (to see small numbers) when you use "log" in
Upload speed graph, colours defined in hex, minus the #. If
scale is non-zero, it becomes the scale for the graph. Uses a
logarithmic scale (to see small numbers) when you use "log" in
stead of "normal".
@ -1766,12 +1767,12 @@ conky(1) conky(1)
voffset (pixels)
Change vertical offset by N pixels. Negative values will cause
Change vertical offset by N pixels. Negative values will cause
text to overlap. See also $offset.
voltage_mv (n)
Returns CPU #n's voltage in mV. CPUs are counted from 1. If
Returns CPU #n's voltage in mV. CPUs are counted from 1. If
omitted, the parameter defaults to 1.
@ -1890,12 +1891,12 @@ conky(1) conky(1)
if_xmms2_connected
Display everything between $if_xmms2_connected and the matching
Display everything between $if_xmms2_connected and the matching
$endif if xmms2 is running.
eve api_userid api_key character_id
Fetches your currently training skill from the Eve Online API
Fetches your currently training skill from the Eve Online API
servers (http://www.eve-online.com/) and displays the skill
along with the remaining training time.
@ -1914,13 +1915,13 @@ conky(1) conky(1)
BUGS
Drawing to root or some other desktop window directly doesn't work with
all window managers. Especially doesn't work well with Gnome and it has
been reported that it doesn't work with KDE either. Nautilus can be
disabled from drawing to desktop with program gconf-editor. Uncheck
show_desktop in /apps/nautilus/preferences/. There is -w switch in
Conky to set some specific window id. You might find xwininfo -tree
useful to find the window to draw to. You can also use -o argument
been reported that it doesn't work with KDE either. Nautilus can be
disabled from drawing to desktop with program gconf-editor. Uncheck
show_desktop in /apps/nautilus/preferences/. There is -w switch in
Conky to set some specific window id. You might find xwininfo -tree
useful to find the window to draw to. You can also use -o argument
which makes Conky to create its own window. If you do try running Conky
in its own window, be sure to read up on the own_window_type settings
in its own window, be sure to read up on the own_window_type settings
and experiment.
SEE ALSO
@ -1931,11 +1932,11 @@ conky(1) conky(1)
#conky on irc.freenode.net
COPYING
Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al. Any
Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al. Any
original torsmo code is licensed under the BSD license (see LICENSE.BSD
for a copy). All code written since the fork of torsmo is licensed un
der the GPL (see LICENSE.GPL for a copy), except where noted different
ly (such as in portmon code, timed thread code, and audacious code
ly (such as in portmon code, timed thread code, and audacious code
which are LGPL, and prss which is an MIT-style license).
AUTHORS

View File

@ -1417,7 +1417,7 @@ Download and parse RSS feeds. Action may be one of the following: feed_title, it
.TP
\fB\*(T<\fBtab\fR\*(T>\fR \*(T<\fB(width, (start))\fR\*(T>
Puts a tab of the specified width, starting from column 'start'.
Puts a tab of the specified width, starting from column 'start'. The unit is pixels for both arguments.
.TP
\fB\*(T<\fBtail\fR\*(T>\fR \*(T<\fBlogfile lines (interval)\fR\*(T>

View File

@ -855,6 +855,7 @@ static void free_text_objects(struct text_object *root)
case OBJ_execi:
case OBJ_execibar:
case OBJ_execigraph:
case OBJ_execigauge:
free(data.execi.cmd);
free(data.execi.buffer);
break;
@ -1411,14 +1412,22 @@ static struct text_object *construct_text_object(const char *s,
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
END OBJ(execp, 0)
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
#define SIZE_DEFAULTS(arg) { \
obj->a = default_##arg##_width; \
obj->b = default_##arg##_height; \
}
END OBJ(execgauge, 0)
SIZE_DEFAULTS(gauge);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
END OBJ(execbar, 0)
SIZE_DEFAULTS(bar);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
END OBJ(execgraph, 0)
SIZE_DEFAULTS(graph);
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
END OBJ(execibar, 0)
int n;
SIZE_DEFAULTS(bar);
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
char buf[256];
@ -1432,6 +1441,7 @@ static struct text_object *construct_text_object(const char *s,
}
END OBJ(execigraph, 0)
int n;
SIZE_DEFAULTS(graph);
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
char buf[256];
@ -1443,6 +1453,20 @@ static struct text_object *construct_text_object(const char *s,
} else {
obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
}
END OBJ(execigauge, 0)
int n;
SIZE_DEFAULTS(gauge);
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
char buf[256];
ERR("${execigauge <interval> command}");
obj->type = OBJ_text;
snprintf(buf, 256, "${%s}", s);
obj->data.s = strndup(buf, text_buffer_size);
} else {
obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
}
END OBJ(execi, 0)
int n;
@ -3020,12 +3044,12 @@ static inline double get_barnum(char *buf)
}
if (sscanf(buf, "%lf", &barnum) == 0) {
ERR("reading execbar value failed (perhaps it's not the "
ERR("reading exec value failed (perhaps it's not the "
"correct format?)");
return -1;
}
if (barnum > 100.0 || barnum < 0.0) {
ERR("your execbar value is not between 0 and 100, "
ERR("your exec value is not between 0 and 100, "
"therefore it will be ignored");
return -1;
}
@ -3192,7 +3216,7 @@ static void generate_text_internal(char *p, int p_max_size,
}
OBJ(cpu) {
if (obj->data.cpu_index > info.cpu_count) {
printf("obj->data.cpu_index %i info.cpu_count %i",
ERR("obj->data.cpu_index %i info.cpu_count %i",
obj->data.cpu_index, info.cpu_count);
CRIT_ERR("attempting to use more CPUs than you have!");
}
@ -3549,7 +3573,7 @@ static void generate_text_internal(char *p, int p_max_size,
if (barnum >= 0.0) {
barnum /= 100;
new_bar(p, 0, 6, round_to_int(barnum * 255.0));
new_gauge(p, obj->a, obj->b, round_to_int(barnum * 255.0));
}
}
OBJ(execbar) {
@ -3560,7 +3584,7 @@ static void generate_text_internal(char *p, int p_max_size,
if (barnum >= 0.0) {
barnum /= 100;
new_bar(p, 0, 6, round_to_int(barnum * 255.0));
new_bar(p, obj->a, obj->b, round_to_int(barnum * 255.0));
}
}
OBJ(execgraph) {
@ -3578,7 +3602,7 @@ static void generate_text_internal(char *p, int p_max_size,
barnum = get_barnum(p);
if (barnum >= 0.0) {
new_graph(p, 0, 25, obj->c, obj->d, round_to_int(barnum),
new_graph(p, obj->a, obj->b, obj->c, obj->d, round_to_int(barnum),
100, 1, showaslog);
}
}
@ -3595,7 +3619,7 @@ static void generate_text_internal(char *p, int p_max_size,
}
obj->data.execi.last_update = current_update_time;
}
new_bar(p, 0, 6, round_to_int(obj->f));
new_bar(p, obj->a, obj->b, round_to_int(obj->f));
}
OBJ(execigraph) {
if (current_update_time - obj->data.execi.last_update
@ -3610,7 +3634,22 @@ static void generate_text_internal(char *p, int p_max_size,
}
obj->data.execi.last_update = current_update_time;
}
new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 1, FALSE);
new_graph(p, obj->a, obj->b, obj->c, obj->d, (int) (obj->f), 100, 1, FALSE);
}
OBJ(execigauge) {
if (current_update_time - obj->data.execi.last_update
>= obj->data.execi.interval) {
double barnum;
read_exec(obj->data.execi.cmd, p, text_buffer_size);
barnum = get_barnum(p);
if (barnum >= 0.0) {
obj->f = 255 * barnum / 100.0;
}
obj->data.execi.last_update = current_update_time;
}
new_gauge(p, obj->a, obj->b, round_to_int(obj->f));
}
OBJ(execi) {
if (current_update_time - obj->data.execi.last_update
@ -4940,6 +4979,7 @@ static inline int get_string_width_special(char *s)
*(p + i) = *(p + i + 1);
}
if (specials[special_index + idx].type == GRAPH
|| specials[special_index + idx].type == GAUGE
|| specials[special_index + idx].type == BAR) {
width += specials[special_index + idx].width;
}
@ -5088,11 +5128,12 @@ static void text_size_updater(char *s)
*p = SPECIAL_CHAR;
if (specials[special_index].type == BAR
|| specials[special_index].type == GAUGE
|| specials[special_index].type == GRAPH) {
w += specials[special_index].width;
if (specials[special_index].height > last_font_height) {
last_font_height = specials[special_index].height;
last_font_height += font_ascent();
last_font_height += font_height();
}
} else if (specials[special_index].type == OFFSET) {
if (specials[special_index].arg > 0) {
@ -5251,7 +5292,7 @@ static void draw_line(char *s)
#ifdef X11
char *p;
int cur_y_add = 0;
short font_h;
int font_h;
char *tmp_str;
#endif /* X11 */
@ -5319,7 +5360,7 @@ static void draw_line(char *s)
bar_usage = specials[special_index].arg;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_height()) {
if (h < font_h) {
by -= h / 2 - 1;
}
w = specials[special_index].width;
@ -5337,18 +5378,18 @@ static void draw_line(char *s)
by, w, h);
XFillRectangle(display, window.drawable, window.gc, cur_x,
by, w * bar_usage / 255, h);
if (specials[special_index].height > cur_y_add
&& specials[special_index].height > font_h) {
cur_y_add = specials[special_index].height;
if (h > cur_y_add
&& h > font_h) {
cur_y_add = h;
}
break;
}
case GAUGE: /* new GAUGE */
{
int h, by = 0;
int h, by = 0;
unsigned long last_colour = current_color;
float angle, px,py;
float angle, px, py;
int usage;
if (cur_x - text_start_x > maximum_width
@ -5359,7 +5400,7 @@ static void draw_line(char *s)
h = specials[special_index].height;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_height()) {
if (h < font_h) {
by -= h / 2 - 1;
}
w = specials[special_index].width;
@ -5371,24 +5412,24 @@ static void draw_line(char *s)
}
XSetLineAttributes(display, window.gc, 1, LineSolid,
CapButt, JoinMiter);
CapButt, JoinMiter);
XDrawArc(display, window.drawable, window.gc,
cur_x, by, w * 2.0, h * 2.0, 0, 180*64);
cur_x, by, w, h * 2, 0, 180*64);
#ifdef MATH
usage =specials[special_index].arg;
angle = (3.14)*(float)(usage)/255.;
px = (float)(cur_x+w)-(float)(w)*cos(angle);
py = (float)(by+h)-(float)(h)*sin(angle);
usage = specials[special_index].arg;
angle = (M_PI)*(float)(usage)/255.;
px = (float)(cur_x+(w/2.))-(float)(w/2.)*cos(angle);
py = (float)(by+(h))-(float)(h)*sin(angle);
XDrawLine(display, window.drawable, window.gc,
cur_x + w, by+h, (int)(px), (int)(py));
cur_x + (w/2.), by+(h), (int)(px), (int)(py));
#endif
if (specials[special_index].height > cur_y_add
&& specials[special_index].height > font_h) {
cur_y_add = specials[special_index].height;
if (h > cur_y_add
&& h > font_h) {
cur_y_add = h;
}
set_foreground_color(last_colour);
@ -5412,7 +5453,7 @@ static void draw_line(char *s)
h = specials[special_index].height;
by = cur_y - (font_ascent() / 2) - 1;
if (h < font_height()) {
if (h < font_h) {
by -= h / 2 - 1;
}
w = specials[special_index].width;
@ -5461,9 +5502,9 @@ static void draw_line(char *s)
by + h - specials[special_index].graph[j] *
(h - 1) / specials[special_index].graph_scale);
}
if (specials[special_index].height > cur_y_add
&& specials[special_index].height > font_h) {
cur_y_add = specials[special_index].height;
if (h > cur_y_add
&& h > font_h) {
cur_y_add = h;
}
/* if (draw_mode == BG) {
set_foreground_color(default_bg_color);
@ -5481,37 +5522,37 @@ static void draw_line(char *s)
char *tmp_min_str;
char *tmp_sec_str;
unsigned short int timeunits;
if(seconds!=0){
if (seconds != 0) {
timeunits = seconds / 86400; seconds %= 86400;
if( timeunits > 0 ) {
if (timeunits > 0) {
asprintf(&tmp_day_str, "%dd", timeunits);
}else{
} else {
tmp_day_str = strdup("");
}
timeunits = seconds / 3600; seconds %= 3600;
if( timeunits > 0 ) {
if (timeunits > 0) {
asprintf(&tmp_hour_str, "%dh", timeunits);
}else{
} else {
tmp_hour_str = strdup("");
}
timeunits = seconds / 60; seconds %= 60;
if(timeunits > 0) {
if (timeunits > 0) {
asprintf(&tmp_min_str, "%dm", timeunits);
}else{
} else {
tmp_min_str = strdup("");
}
if(seconds > 0) {
if (seconds > 0) {
asprintf(&tmp_sec_str, "%ds", seconds);
}else{
} else {
tmp_sec_str = strdup("");
}
asprintf(&tmp_str, "%s%s%s%s", tmp_day_str, tmp_hour_str, tmp_min_str, tmp_sec_str);
free(tmp_day_str); free(tmp_hour_str); free(tmp_min_str); free(tmp_sec_str);
}else{
asprintf(&tmp_str, "Range not possible"); //should never happen, but better safe then sorry
} else {
asprintf(&tmp_str, "Range not possible"); // should never happen, but better safe then sorry
}
cur_x += (w / 2) - (font_ascent() * (strlen(tmp_str) / 2));
cur_y += font_height() / 2;
cur_y += font_h / 2;
draw_string(tmp_str);
free(tmp_str);
cur_x = tmp_x;
@ -5522,7 +5563,7 @@ static void draw_line(char *s)
int tmp_x = cur_x;
int tmp_y = cur_y;
cur_x += font_ascent() / 2;
cur_y += font_height() / 2;
cur_y += font_h / 2;
tmp_str = (char *)
calloc(log10(floor(specials[special_index].graph_scale)) + 4,
sizeof(char));
@ -5549,6 +5590,7 @@ static void draw_line(char *s)
cur_y += font_ascent();
}
set_font();
font_h = font_height();
break;
}
case FG:
@ -5641,14 +5683,13 @@ static void draw_line(char *s)
p++;
}
if (cur_y_add > 0) {
cur_y += cur_y_add;
cur_y -= font_descent();
}
draw_string(s);
cur_y += font_descent();
#endif /* X11 */
}

View File

@ -43,8 +43,8 @@ struct special_t *specials = NULL;
unsigned int special_count;
int default_bar_width = 0, default_bar_height = 6;
int default_graph_width = 25, default_graph_height = 25;
int default_gauge_width = 0, default_gauge_height = 25;
int default_graph_width = 0, default_graph_height = 25;
int default_gauge_width = 50, default_gauge_height = 25;
/*
* Scanning arguments to various special text objects

View File

@ -6,7 +6,6 @@
*
* Please see COPYING for details
*
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
* Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.

View File

@ -101,6 +101,7 @@ enum text_object_type {
OBJ_execgraph,
OBJ_execibar,
OBJ_execigraph,
OBJ_execigauge,
OBJ_execp,
OBJ_execpi,
OBJ_freq,