diff --git a/src/conky.c b/src/conky.c index 8e649ab5..713e480a 100644 --- a/src/conky.c +++ b/src/conky.c @@ -970,19 +970,6 @@ void generate_text_internal(char *p, int p_max_size, evaluate(obj->data.s, p, p_max_size); } } -#ifdef HDDTEMP - OBJ(hddtemp) { - short val; - char unit; - - if (get_hddtemp_info(obj->data.s, &val, &unit)) { - snprintf(p, p_max_size, "N/A"); - } else { - temp_print(p, p_max_size, (double)val, - (unit == 'C' ? TEMP_CELSIUS : TEMP_FAHRENHEIT)); - } - } -#endif OBJ(if_empty) { char buf[max_user_text]; struct information *tmp_info = diff --git a/src/core.c b/src/core.c index 11adcde1..9b9db58c 100644 --- a/src/core.c +++ b/src/core.c @@ -1277,6 +1277,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(hddtemp, &update_hddtemp) if (arg) obj->data.s = strndup(arg, text_buffer_size); + obj->callbacks.print = &print_hddtemp; obj->callbacks.free = &free_hddtemp; #endif /* HDDTEMP */ #ifdef TCP_PORT_MONITOR diff --git a/src/hddtemp.c b/src/hddtemp.c index 41781ce3..e5a47598 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -30,6 +30,7 @@ #include "conky.h" #include "logging.h" +#include "temphelper.h" #include "text_object.h" #include #include @@ -241,7 +242,7 @@ void free_hddtemp(struct text_object *obj) } } -int get_hddtemp_info(const char *dev, short *val, char *unit) +static int get_hddtemp_info(const char *dev, short *val, char *unit) { struct hdd_info *hdi = hdd_info_head.next; @@ -258,3 +259,16 @@ int get_hddtemp_info(const char *dev, short *val, char *unit) *unit = hdi->unit; return 0; } + +void print_hddtemp(struct text_object *obj, char *p, int p_max_size) +{ + short val; + char unit; + + if (get_hddtemp_info(obj->data.s, &val, &unit)) { + snprintf(p, p_max_size, "N/A"); + } else { + temp_print(p, p_max_size, (double)val, + (unit == 'C' ? TEMP_CELSIUS : TEMP_FAHRENHEIT)); + } +} diff --git a/src/hddtemp.h b/src/hddtemp.h index c6d982a1..8b4941b8 100644 --- a/src/hddtemp.h +++ b/src/hddtemp.h @@ -7,6 +7,6 @@ void set_hddtemp_host(const char *); void set_hddtemp_port(const char *); void update_hddtemp(void); void free_hddtemp(struct text_object *); -int get_hddtemp_info(const char *, short *, char *); +void print_hddtemp(struct text_object *, char *, int); #endif /*HDDTEMP_H_*/