From 940c63233f69d71e393642ff8a1e443d84941ce0 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Fri, 26 Aug 2005 02:52:54 +0000 Subject: [PATCH] small fixes. the code feels sexy right now. git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@187 7f574dfc-610e-0410-a909-a81674777703 --- src/common.c | 3 +++ src/conky.c | 26 ++++++++++++-------------- src/conky.h | 4 ++++ src/linux.c | 4 ++-- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/common.c b/src/common.c index f61d6b85..8621a760 100644 --- a/src/common.c +++ b/src/common.c @@ -196,6 +196,9 @@ void update_stuff() if (NEED(INFO_NET)) update_net_stats(); + if (NEED(INFO_DISKIO)) + update_diskio(); + if (NEED(INFO_WIFI)) update_wifi_stats(); diff --git a/src/conky.c b/src/conky.c index f4f814af..a36bf1e1 100644 --- a/src/conky.c +++ b/src/conky.c @@ -187,6 +187,7 @@ static void load_fonts() ERR("can't load font '%s'", fonts[i].name); if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) { CRIT_ERR("can't load font '%s'", "fixed"); + printf("loaded fixed?\n"); } } } @@ -498,7 +499,7 @@ static void new_font(char *buf, char * args) { int tmp = selected_font; selected_font = s->font_added = addfont(args); load_fonts(); - set_font(); +// set_font(); selected_font = tmp; } } @@ -1014,8 +1015,8 @@ if (s[0] == '#') { (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b); END OBJ(cpugraph, INFO_CPU) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e); - END OBJ(diskio, 0) - END OBJ(diskiograph, 0) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e); + END OBJ(diskio, INFO_DISKIO) + END OBJ(diskiograph, INFO_DISKIO) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e); END OBJ(color, 0) #ifdef X11 obj->data.l = arg ? get_x11_color(arg) : default_fg_color; @@ -1712,21 +1713,19 @@ static void generate_text() } #endif /* X11 */ OBJ(diskio) { - int io = get_diskio(); - if (io > 1024) { + if (diskio_value > 1024) { snprintf(p, n, "%.1fM", - (double)io/1024); - } else if (io > 0) { - snprintf(p, n, "%dK", io); + (double)diskio_value/1024); + } else if (diskio_value > 0) { + snprintf(p, n, "%dK", diskio_value); } else { - snprintf(p, n, "%d", io); + snprintf(p, n, "%d", diskio_value); } } OBJ(diskiograph) { - int io = get_diskio(); new_graph(p, obj->a, obj->b, obj->c, obj->d, - (unsigned int) (io), obj->e, 1); + diskio_value, obj->e, 1); } OBJ(downspeed) { @@ -3137,12 +3136,11 @@ static void draw_line(char *s) int by; #ifdef XFT if (use_xft) { - by = cur_y - (font_ascent() + - h) / 2 - 1; + by = cur_y - (font_ascent() + h) / 2 + 1; } else #endif { - by = cur_y - (font_ascent()/2); + by = cur_y - (font_ascent()/2) + 1; } w = specials[special_index].width; if (w == 0) diff --git a/src/conky.h b/src/conky.h index e91ad041..ffc0f1e7 100644 --- a/src/conky.h +++ b/src/conky.h @@ -57,6 +57,8 @@ struct net_stat { double net_rec[15], net_trans[15]; }; +unsigned int diskio_value; + struct fs_stat { int fd; char *path; @@ -111,6 +113,7 @@ enum { INFO_MLDONKEY = 18, #endif INFO_WIFI = 19, + INFO_DISKIO = 20, }; @@ -258,6 +261,7 @@ extern int no_buffers; /* system dependant (in linux.c) */ +void update_diskio(void); void prepare_update(void); void update_uptime(void); void update_meminfo(void); diff --git a/src/linux.c b/src/linux.c index 8a98f870..388ba9fc 100644 --- a/src/linux.c +++ b/src/linux.c @@ -1087,7 +1087,7 @@ void update_top() process_find_top(info.cpu, info.memu); } -unsigned int get_diskio() +void update_diskio() { static unsigned int last = 0; static FILE* fp; @@ -1129,5 +1129,5 @@ unsigned int get_diskio() } last = current; - return tot; + diskio_value = tot; }