1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

make specifying hdd names more flexible

* the macro DEV_NAME() "removes" any leading "/dev/"
  if existing
* the only object that needs the full path is hddtemp,
  so add code there to add "/dev/" if necessary
  (can't be done via macro)
* attempt to fix also the hddtemp output, as the
  "degree"-sign seems to be inserted in utf-8 and
  printed in latin.
* hddtemp breaks the rules by inserting the unit
  itself, but as it could be either "C" or "F", this
  would lead to confusion otherwise


git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1091 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Phil 2008-03-31 15:33:54 +00:00
parent be2cd44e6d
commit d923325773
2 changed files with 17 additions and 9 deletions

View File

@ -2284,6 +2284,9 @@ void scan_mixer_bar(const char *arg, int *a, int *w, int *h)
}
}
/* strip a leading /dev/ if any */
#define DEV_NAME(x) strncmp(x, "/dev/", 5) ? x : x + 5
/* construct_text_object() creates a new text_object */
static struct text_object *construct_text_object(const char *s,
const char *arg, unsigned int object_count,
@ -2459,7 +2462,7 @@ static struct text_object *construct_text_object(const char *s,
#if defined(__linux__)
END OBJ(disk_protect, 0)
if (arg)
obj->data.s = strdup(arg);
obj->data.s = strdup(DEV_NAME(arg));
else
CRIT_ERR("disk_protect needs an argument");
END OBJ(i8k_version, INFO_I8K)
@ -2510,7 +2513,7 @@ static struct text_object *construct_text_object(const char *s,
CRIT_ERR("get_ioscheduler needs an argument (e.g. hda)");
obj->data.s = 0;
} else
obj->data.s = strdup(arg);
obj->data.s = strdup(DEV_NAME(arg));
END OBJ(laptop_mode, 0)
END OBJ(pb_battery, 0)
if (arg && strcmp(arg, "status") == 0) {
@ -2602,24 +2605,24 @@ static struct text_object *construct_text_object(const char *s,
}
END OBJ(diskio, INFO_DISKIO)
if (arg) {
obj->data.diskio = prepare_diskio_stat(arg);
obj->data.diskio = prepare_diskio_stat(DEV_NAME(arg));
} else {
obj->data.diskio = NULL;
}
END OBJ(diskio_read, INFO_DISKIO)
if (arg) {
obj->data.diskio = prepare_diskio_stat(arg);
obj->data.diskio = prepare_diskio_stat(DEV_NAME(arg));
} else {
obj->data.diskio = NULL;
}
END OBJ(diskio_write, INFO_DISKIO)
if (arg) {
obj->data.diskio = prepare_diskio_stat(arg);
obj->data.diskio = prepare_diskio_stat(DEV_NAME(arg));
} else {
obj->data.diskio = NULL;
}
END OBJ(diskiograph, INFO_DISKIO)
char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
char *buf = scan_graph(DEV_NAME(arg), &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e);
if (buf) {
@ -2629,7 +2632,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.diskio = NULL;
}
END OBJ(diskiograph_read, INFO_DISKIO)
char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
char *buf = scan_graph(DEV_NAME(arg), &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e);
if (buf) {
@ -2639,7 +2642,7 @@ static struct text_object *construct_text_object(const char *s,
obj->data.diskio = NULL;
}
END OBJ(diskiograph_write, INFO_DISKIO)
char *buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
char *buf = scan_graph(DEV_NAME(arg), &obj->a, &obj->b, &obj->c, &obj->d,
&obj->e);
if (buf) {
@ -5262,7 +5265,7 @@ static void generate_text_internal(char *p, int p_max_size,
} else if (unit == '*') {
snprintf(p, p_max_size, "%s", temp);
} else {
snprintf(p, p_max_size, "%s°%c", temp, unit);
snprintf(p, p_max_size, "%s%c", temp, unit);
}
}
#endif

View File

@ -53,7 +53,12 @@ int scan_hddtemp(const char *arg, char **dev, char **addr, int *port)
return -1;
}
if (strncmp(buf1, "/dev/", 5)) {
strncpy(buf1 + 5, buf1, 32 - 5);
strncpy(buf1, "/dev/", 5);
}
*dev = strdup(buf1);
if (ret >= 2) {
*addr = strdup(buf2);
} else {