mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
fixed hddtemp problems as well as some other misc things
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1112 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
5c01c5991e
commit
39a00f4cfa
15
src/conky.c
15
src/conky.c
@ -239,7 +239,7 @@ void set_first_font(const char *data_in)
|
||||
font_count++;
|
||||
}
|
||||
if (strlen(data_in) > 1) {
|
||||
strncpy(fonts[0].name, data_in, text_buffer_size);
|
||||
strncpy(fonts[0].name, data_in, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
#ifdef XFT
|
||||
fonts[0].font_alpha = 0xffff;
|
||||
#endif
|
||||
@ -680,7 +680,7 @@ static const char *scan_bar(const char *args, int *w, int *h)
|
||||
static char *scan_font(const char *args)
|
||||
{
|
||||
if (args && *args) {
|
||||
return strndup(args, text_buffer_size);
|
||||
return strndup(args, DEFAULT_TEXT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -802,6 +802,7 @@ static char *scan_graph(const char *args, int *w, int *h,
|
||||
unsigned int *scale)
|
||||
{
|
||||
char buf[64];
|
||||
buf[0] = 0;
|
||||
|
||||
/* zero width means all space that is available */
|
||||
*w = 0;
|
||||
@ -2237,6 +2238,7 @@ static void free_text_objects(unsigned int count, struct text_object *objs)
|
||||
case OBJ_hddtemp:
|
||||
free(objs[i].data.hddtemp.dev);
|
||||
free(objs[i].data.hddtemp.addr);
|
||||
free(objs[i].data.hddtemp.temp);
|
||||
break;
|
||||
#endif
|
||||
case OBJ_entropy_avail:
|
||||
@ -3774,7 +3776,7 @@ static struct text_object *construct_text_object(const char *s,
|
||||
#ifdef HDDTEMP
|
||||
END OBJ(hddtemp, 0)
|
||||
if (!arg || scan_hddtemp(arg, &obj->data.hddtemp.dev,
|
||||
&obj->data.hddtemp.addr, &obj->data.hddtemp.port)) {
|
||||
&obj->data.hddtemp.addr, &obj->data.hddtemp.port, &obj->data.hddtemp.temp)) {
|
||||
ERR("hddtemp needs arguments");
|
||||
obj->type = OBJ_text;
|
||||
obj->data.s = strndup("${hddtemp}", text_buffer_size);
|
||||
@ -5313,8 +5315,13 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
#ifdef HDDTEMP
|
||||
OBJ(hddtemp) {
|
||||
if (obj->data.hddtemp.update_time < current_update_time - 30) {
|
||||
obj->data.hddtemp.temp = get_hddtemp_info(obj->data.hddtemp.dev,
|
||||
char *str = get_hddtemp_info(obj->data.hddtemp.dev,
|
||||
obj->data.hddtemp.addr, obj->data.hddtemp.port, &obj->data.hddtemp.unit);
|
||||
if (str) {
|
||||
strncpy(obj->data.hddtemp.temp, str, text_buffer_size);
|
||||
} else {
|
||||
obj->data.hddtemp.temp[0] = 0;
|
||||
}
|
||||
obj->data.hddtemp.update_time = current_update_time;
|
||||
}
|
||||
if (!obj->data.hddtemp.temp) {
|
||||
|
@ -712,7 +712,7 @@ void update_xmms2(void);
|
||||
|
||||
/* in hddtemp.c */
|
||||
#ifdef HDDTEMP
|
||||
int scan_hddtemp(const char *arg, char **dev, char **addr, int *port);
|
||||
int scan_hddtemp(const char *arg, char **dev, char **addr, int *port, char **temp);
|
||||
char *get_hddtemp_info(char *dev, char *addr, int port, char *unit);
|
||||
#endif /* HDDTEMP */
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
char buf[BUFLEN];
|
||||
|
||||
int scan_hddtemp(const char *arg, char **dev, char **addr, int *port)
|
||||
int scan_hddtemp(const char *arg, char **dev, char **addr, int *port, char** temp)
|
||||
{
|
||||
char buf1[32], buf2[64];
|
||||
int n, ret;
|
||||
@ -71,6 +71,9 @@ int scan_hddtemp(const char *arg, char **dev, char **addr, int *port)
|
||||
*port = PORT;
|
||||
}
|
||||
|
||||
*temp = malloc(text_buffer_size);
|
||||
memset(*temp, 0, text_buffer_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -179,7 +182,7 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit)
|
||||
p++;
|
||||
*unit = *p;
|
||||
if (!strncmp(out, "NA", 2)) {
|
||||
strcpy(buf, "N/A");
|
||||
strncpy(buf, "N/A", BUFLEN);
|
||||
r = buf;
|
||||
} else {
|
||||
r = out;
|
||||
@ -193,6 +196,9 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port, char *unit)
|
||||
}
|
||||
p++;
|
||||
}
|
||||
if (!p && i < 5) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (0);
|
||||
|
@ -517,10 +517,10 @@ long get_x11_color(const char *name)
|
||||
if (!XParseColor(display, DefaultColormap(display, screen), name, &color)) {
|
||||
/* lets check if it's a hex colour with the # missing in front
|
||||
* if yes, then do something about it */
|
||||
char newname[64];
|
||||
char newname[DEFAULT_TEXT_BUFFER_SIZE];
|
||||
|
||||
newname[0] = '#';
|
||||
strncpy(&newname[1], name, 62);
|
||||
strncpy(&newname[1], name, DEFAULT_TEXT_BUFFER_SIZE - 1);
|
||||
/* now lets try again */
|
||||
if (!XParseColor(display, DefaultColormap(display, screen), &newname[0],
|
||||
&color)) {
|
||||
|
Loading…
Reference in New Issue
Block a user