mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
hddtemp: convert to callbacks.print
This commit is contained in:
parent
49cacbbc91
commit
ac80e6f55f
13
src/conky.c
13
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 =
|
||||
|
@ -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
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "temphelper.h"
|
||||
#include "text_object.h"
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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_*/
|
||||
|
Loading…
Reference in New Issue
Block a user