1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-11 10:38:12 +00:00

$execibar and $execigraph were broken. thanks to GimmeFuel for the heads-up

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@188 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-08-26 03:26:23 +00:00
parent 940c63233f
commit 2210a8459f
3 changed files with 18 additions and 17 deletions

View File

@ -830,6 +830,7 @@ struct text_object {
int type;
int a, b;
unsigned int c, d, e;
float f;
union {
char *s; /* some string */
int i; /* some integer */
@ -1070,7 +1071,7 @@ if (s[0] == '#') {
snprintf(buf, 256, "${%s}", s);
obj->data.s = strdup(buf);
} else {
obj->data.s = strdup(arg + n);
obj->data.execi.cmd = strdup(arg + n);
}
END OBJ(execigraph, 0) unsigned int n;
if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
@ -1080,7 +1081,7 @@ if (s[0] == '#') {
snprintf(buf, 256, "${%s}", s);
obj->data.s = strdup(buf);
} else {
obj->data.s = strdup(arg + n);
obj->data.execi.cmd = strdup(arg + n);
}
END OBJ(execi, 0) unsigned int n;
@ -1859,10 +1860,10 @@ static void generate_text()
}
OBJ(execibar) {
if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
new_bar(p, 0, 4, (int) obj->data.execi.data);
new_bar(p, 0, 4, (int) obj->f);
} else {
char *p2 = p;
FILE *fp = popen(obj->data.s, "r");
FILE *fp = popen(obj->data.execi.cmd, "r");
int n2 = fread(p, 1, n, fp);
(void) pclose(fp);
p[n2] = '\0';
@ -1874,15 +1875,15 @@ static void generate_text()
*p2 = ' ';
p2++;
}
double barnum;
if (sscanf(p, "%lf", &barnum) == 0) {
float barnum;
if (sscanf(p, "%f", &barnum) == 0) {
ERR("reading execibar value failed (perhaps it's not the correct format?)");
}
if (barnum > 100 || barnum < 0) {
ERR("your execibar value is not between 0 and 100, therefore it will be ignored");
} else {
obj->data.execi.data = 255 * barnum / 100.0;
new_bar(p, 0, 4, (int) obj->data.execi.data);
obj->f = 255 * barnum / 100.0;
new_bar(p, 0, 4, (int) obj->f);
}
obj->data.execi.last_update =
current_update_time;
@ -1890,10 +1891,10 @@ static void generate_text()
}
OBJ(execigraph) {
if (current_update_time - obj->data.execi.last_update < obj->data.execi.interval) {
new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->data.execi.data), obj->e, 0);
new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 0);
} else {
char *p2 = p;
FILE *fp = popen(obj->data.s, "r");
FILE *fp = popen(obj->data.execi.cmd, "r");
int n2 = fread(p, 1, n, fp);
(void) pclose(fp);
p[n2] = '\0';
@ -1905,15 +1906,15 @@ static void generate_text()
*p2 = ' ';
p2++;
}
double barnum;
if (sscanf(p, "%lf", &barnum) == 0) {
float barnum;
if (sscanf(p, "%f", &barnum) == 0) {
ERR("reading execigraph value failed (perhaps it's not the correct format?)");
}
if (barnum > 100 || barnum < 0) {
ERR("your execigraph value is not between 0 and 100, therefore it will be ignored");
} else {
obj->data.execi.data = barnum;
new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->data.execi.data), obj->e, 1);
obj->f = barnum;
new_graph(p, 0, 25, obj->c, obj->d, (int) (obj->f), 100, 1);
}
obj->data.execi.last_update = current_update_time;

View File

@ -65,5 +65,5 @@ void client()
close(sockfd);
return 0;
return;
}

View File

@ -34,7 +34,7 @@ static char *data;
#define BACKLOG 10 // how many pending connections queue will hold
void sigchld_handler(int s)
void sigchld_handler(/*int s*/)
{
while(wait(NULL) > 0);
}
@ -111,7 +111,7 @@ void *daemon_loop()
void daemon_run(const char *s)
{
/* create thread, keep an eye on it */
data = s;
data = (char *)s;
int iret;
if (!daemon_status) {
daemon_status = 1;