mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
yum, net graphs
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@28 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
1e5181ce85
commit
68cca1fd8d
@ -1,3 +1,9 @@
|
||||
2005-07-30
|
||||
* finalized graphing code, see $cpugraph, $memgraph, $execgraph,
|
||||
$downspeedgraph, and $upspeedgraph
|
||||
* added override_utf8_locale option
|
||||
* poop
|
||||
|
||||
2005-07-28
|
||||
* Added new graphing code, such as $cpugraph
|
||||
* small fixes all round
|
||||
|
5
README
5
README
@ -93,6 +93,7 @@
|
||||
mldonkey_login Mldonkey login, default none
|
||||
mldonkey_password Mldonkey password, default none
|
||||
net_avg_samples The number of samples to average for net data
|
||||
override_utf8_locale Force UTF8? requires XFT
|
||||
own_window Boolean, create own window to draw?
|
||||
pad_percents Pad percentages to this many decimals (0 = no
|
||||
padding)
|
||||
@ -157,9 +158,11 @@
|
||||
cpu CPU usage in percents
|
||||
cpubar (height) Bar that shows CPU usage, height is
|
||||
bar's height in pixels
|
||||
cpugraph (height),(width)CPU usage graph
|
||||
downspeed net Download speed in kilobytes
|
||||
downspeedf net Download speed in kilobytes with one
|
||||
decimal
|
||||
downspeedgraph net (height),(width) Download speed graph
|
||||
exec shell command Executes a shell command and displays
|
||||
the output in conky. warning: this
|
||||
takes a lot more resources than other
|
||||
@ -170,6 +173,7 @@
|
||||
will use that number for a bar.
|
||||
The size for the bar is currently fixed,
|
||||
but that may change in the future.
|
||||
execgraph shell command Same as execbar, but graphs values
|
||||
execi interval, shell Same as exec but with specific interval.
|
||||
command Interval can't be less than
|
||||
update_interval in configuration.
|
||||
@ -295,6 +299,7 @@
|
||||
upspeed net Upload speed in kilobytes
|
||||
upspeedf net Upload speed in kilobytes with one
|
||||
decimal
|
||||
upspeedgraph net (height),(width) Upload speed graph
|
||||
uptime Uptime
|
||||
uptime_short Uptime in a shorter format
|
||||
|
||||
|
2
common.c
2
common.c
@ -146,7 +146,7 @@ void format_seconds_short(char *buf, unsigned int n, long t)
|
||||
static double last_meminfo_update;
|
||||
static double last_fs_update;
|
||||
|
||||
unsigned int need_mask;
|
||||
unsigned long long need_mask;
|
||||
|
||||
void update_stuff()
|
||||
{
|
||||
|
76
conky.c
76
conky.c
@ -242,8 +242,8 @@ static struct special_t *new_special(char *buf, int t)
|
||||
buf[0] = SPECIAL_CHAR;
|
||||
buf[1] = '\0';
|
||||
if (t == GRAPH && specials[special_count].graph == NULL) {
|
||||
if (specials[special_count].height > 0 && specials[special_count].height < MAX_GRAPH_DEPTH)
|
||||
specials[special_count].graph_width = specials[special_count].height;
|
||||
if (specials[special_count].width > 0 && specials[special_count].width < MAX_GRAPH_DEPTH)
|
||||
specials[special_count].graph_width = specials[special_count].width - 3; // subtract 3 for the box
|
||||
else
|
||||
specials[special_count].graph_width = MAX_GRAPH_DEPTH;
|
||||
specials[special_count].graph = calloc(specials[special_count].graph_width, sizeof(double));
|
||||
@ -310,13 +310,14 @@ inline void graph_append(struct special_t *graph, double f) {
|
||||
if (graph->scaled) {
|
||||
graph->graph_scale = 0;
|
||||
}
|
||||
graph->graph[graph->graph_width-1] = f;
|
||||
for (i=0;i<graph->graph_width-1;i++) {
|
||||
graph->graph[i] = graph->graph[i+1];
|
||||
if (graph->scaled && graph->graph[i] > graph->graph_scale) {
|
||||
graph->graph_scale = graph->graph[i];
|
||||
}
|
||||
}
|
||||
graph->graph[graph->graph_width-1] = f;
|
||||
// graph->graph[graph->graph_width-1] = f;
|
||||
}
|
||||
|
||||
static void new_graph(char *buf, int w, int h, double i, int scaled)
|
||||
@ -325,8 +326,11 @@ static void new_graph(char *buf, int w, int h, double i, int scaled)
|
||||
s->width = w;
|
||||
s->height = h;
|
||||
s->scaled = scaled;
|
||||
if (s->width) {
|
||||
s->graph_width = s->width - 3; // subtract 3 for rectangle around
|
||||
}
|
||||
if (scaled) {
|
||||
s->graph_scale = 0;
|
||||
s->graph_scale = 1;
|
||||
}
|
||||
else {
|
||||
s->graph_scale = 100;
|
||||
@ -342,8 +346,8 @@ static const char *scan_graph(const char *args, int *w, int *h)
|
||||
if (args) {
|
||||
int n = 0;
|
||||
if (sscanf(args, "%d,%d %n", h, w, &n) <= 1)
|
||||
sscanf(args, "%d %n", h, &n);
|
||||
args += n;
|
||||
sscanf(args, "%*s %d %n", h, &n);
|
||||
//args += n;
|
||||
}
|
||||
|
||||
return args;
|
||||
@ -574,6 +578,7 @@ enum text_object_type {
|
||||
|
||||
struct text_object {
|
||||
int type;
|
||||
int a, b;
|
||||
union {
|
||||
char *s; /* some string */
|
||||
int i; /* some integer */
|
||||
@ -626,7 +631,6 @@ struct text_object {
|
||||
struct {
|
||||
int a, b;
|
||||
} pair; /* 2 */
|
||||
|
||||
} data;
|
||||
};
|
||||
|
||||
@ -742,8 +746,16 @@ static void construct_text_object(const char *s, const char *arg)
|
||||
END OBJ(downspeed, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||
END OBJ(downspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||
END OBJ(downspeedgraph, INFO_NET)
|
||||
obj->data.net = get_net_stat(arg);
|
||||
(void) scan_graph("", &obj->data.pair.a, &obj->data.pair.b);
|
||||
(void) scan_graph(arg, &obj->a, &obj->b);
|
||||
char buf[64];
|
||||
sscanf(arg, "%63s %*i,%*i %*i", buf);
|
||||
obj->data.net = get_net_stat(buf);
|
||||
if (sscanf(arg, "%*s %d,%d %*d", &obj->a, &obj->b) <= 1) {
|
||||
if (sscanf(arg, "%*s %d,%d", &obj->a, &obj->b) <= 1) {
|
||||
obj->a = 0;
|
||||
obj->b = 25;
|
||||
}
|
||||
}
|
||||
END OBJ(else, 0)
|
||||
if (blockdepth) {
|
||||
text_objects[blockstart[blockdepth - 1] -
|
||||
@ -1121,7 +1133,16 @@ static void construct_text_object(const char *s, const char *arg)
|
||||
END OBJ(upspeed, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||
END OBJ(upspeedf, INFO_NET) obj->data.net = get_net_stat(arg);
|
||||
END OBJ(upspeedgraph, INFO_NET)
|
||||
(void) scan_graph(arg, &obj->data.pair.a, &obj->data.pair.b);
|
||||
(void) scan_graph(arg, &obj->a, &obj->b);
|
||||
char buf[64];
|
||||
sscanf(arg, "%63s %*i,%*i %*i", buf);
|
||||
obj->data.net = get_net_stat(buf);
|
||||
if (sscanf(arg, "%*s %d,%d %*d", &obj->a, &obj->b) <= 1) {
|
||||
if (sscanf(arg, "%*s %d,%d", &obj->a, &obj->b) <= 1) {
|
||||
obj->a = 0;
|
||||
obj->b = 25;
|
||||
}
|
||||
}
|
||||
END OBJ(uptime_short, INFO_UPTIME) END OBJ(uptime, INFO_UPTIME) END
|
||||
OBJ(adt746xcpu, 0) END OBJ(adt746xfan, 0) END
|
||||
#ifdef SETI
|
||||
@ -1402,8 +1423,7 @@ static void generate_text()
|
||||
recv_speed / 1024.0);
|
||||
}
|
||||
OBJ(downspeedgraph) {
|
||||
CRIT_ERR("the net graph stuff is broken right now. don't use it.");
|
||||
new_graph(p, obj->data.pair.a, obj->data.pair.b, (obj->data.net->recv_speed / 1024.0), 1);
|
||||
new_graph(p, obj->a, obj->b, (obj->data.net->recv_speed / 1024.0), 1);
|
||||
}
|
||||
OBJ(else) {
|
||||
if (!if_jumped) {
|
||||
@ -1934,11 +1954,8 @@ static void generate_text()
|
||||
trans_speed / 1024.0);
|
||||
}
|
||||
OBJ(upspeedgraph) {
|
||||
CRIT_ERR("the net graph stuff is broken right now. don't use it.");
|
||||
new_graph(p, obj->data.pair.a,
|
||||
obj->data.pair.b,
|
||||
(obj->data.net->trans_speed / 1024.0), 1);
|
||||
}
|
||||
new_graph(p, obj->a, obj->b, (obj->data.net->trans_speed / 1024.0), 1);
|
||||
}
|
||||
OBJ(uptime_short) {
|
||||
format_seconds_short(p, n,
|
||||
(int) cur->uptime);
|
||||
@ -2692,17 +2709,12 @@ static void draw_line(char *s)
|
||||
int by =
|
||||
cur_y - (font_ascent() +
|
||||
h) / 2 - 1;
|
||||
int line;
|
||||
w = specials[special_index].width;
|
||||
if (w == 0)
|
||||
w = text_start_x +
|
||||
text_width - cur_x - 1;
|
||||
if (w < 0)
|
||||
w = 0;
|
||||
if (w >= specials[special_index].graph_width)
|
||||
line = w/specials[special_index].graph_width+1;
|
||||
else
|
||||
line = 1;
|
||||
XSetLineAttributes(display,
|
||||
window.gc, 1,
|
||||
LineSolid,
|
||||
@ -2713,13 +2725,21 @@ static void draw_line(char *s)
|
||||
window.gc, cur_x,
|
||||
by, w, h);
|
||||
XSetLineAttributes(display,
|
||||
window.gc, line,
|
||||
window.gc, 1,
|
||||
LineSolid,
|
||||
CapButt,
|
||||
JoinMiter);
|
||||
int i;
|
||||
for (i=0;i<specials[special_index].graph_width;i++) {
|
||||
XDrawLine(display, window.drawable, window.gc, cur_x+(i*w*1.0/specials[special_index].graph_width)+2, by+h, cur_x+(i*w*1.0/specials[special_index].graph_width)+2, by+h-specials[special_index].graph[i]*h/specials[special_index].graph_scale); /* this is mugfugly, but it works */
|
||||
int j=0;
|
||||
for (i=0;i<w-3;i++) {
|
||||
if (i / ((float)(w - 3) / (specials[special_index].graph_width)) > j) {
|
||||
j++;
|
||||
}
|
||||
XDrawLine(display, window.drawable, window.gc,
|
||||
cur_x+i+2, by+h,
|
||||
cur_x+i+2,
|
||||
by+h-specials[special_index].graph[j]*h/specials[special_index]
|
||||
.graph_scale); /* this is mugfugly, but it works */
|
||||
}
|
||||
if (specials[special_index].height > font_h) {
|
||||
cur_y += specials[special_index].height;
|
||||
@ -3519,6 +3539,12 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, a) == 0)
|
||||
|
||||
|
||||
|
||||
CONF("override_utf8_locale") {
|
||||
utf8_mode
|
||||
=
|
||||
string_to_bool
|
||||
(value);
|
||||
}
|
||||
#ifdef XDBE
|
||||
CONF("double_buffer") {
|
||||
use_xdbe
|
||||
|
2
conky.h
2
conky.h
@ -237,7 +237,7 @@ struct net_stat *get_net_stat(const char *dev);
|
||||
void update_stuff();
|
||||
|
||||
#define SET_NEED(a) need_mask |= 1 << (a)
|
||||
extern unsigned int need_mask;
|
||||
extern unsigned long long need_mask;
|
||||
|
||||
extern double current_update_time, last_update_time;
|
||||
|
||||
|
@ -98,6 +98,10 @@ cpu_avg_samples 4
|
||||
# set to 1 to disable averaging
|
||||
net_avg_samples 4
|
||||
|
||||
# Force UTF8? note that UTF8 support required XFT
|
||||
override_utf8_locale no
|
||||
|
||||
|
||||
# Add spaces to keep things from moving about? This only affects certain objects.
|
||||
use_spacer no
|
||||
|
||||
@ -139,9 +143,11 @@ metar_station CYBW
|
||||
# cpu CPU usage in percents
|
||||
# cpubar (height) Bar that shows CPU usage, height is
|
||||
# bar's height in pixels
|
||||
# cpugraph (height),(width)CPU usage graph
|
||||
# downspeed net Download speed in kilobytes
|
||||
# downspeedf net Download speed in kilobytes with one
|
||||
# decimal
|
||||
# downspeedgraph net (height),(width) Download speed graph
|
||||
# exec shell command Executes a shell command and displays
|
||||
# the output in conky. warning: this
|
||||
# takes a lot more resources than other
|
||||
@ -152,6 +158,7 @@ metar_station CYBW
|
||||
# will use that number for a bar.
|
||||
# The size for the bar is currently fixed,
|
||||
# but that may change in the future.
|
||||
# execgraph shell command Same as execbar, but graphs values
|
||||
# execi interval, shell Same as exec but with specific interval.
|
||||
# command Interval can't be less than
|
||||
# update_interval in configuration.
|
||||
@ -277,6 +284,7 @@ metar_station CYBW
|
||||
# upspeed net Upload speed in kilobytes
|
||||
# upspeedf net Upload speed in kilobytes with one
|
||||
# decimal
|
||||
# upspeedgraph net (height),(width) Upload speed graph
|
||||
# uptime Uptime
|
||||
# uptime_short Uptime in a shorter format
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user