mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-28 13:00:45 +00:00
Make hddtemp_{host,port} lua settings
This commit is contained in:
parent
31cbd710a6
commit
b863f216b8
@ -2918,14 +2918,6 @@ char load_config_file(const char *f)
|
||||
}
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
#ifdef HDDTEMP
|
||||
CONF("hddtemp_host") {
|
||||
set_hddtemp_host(value);
|
||||
}
|
||||
CONF("hddtemp_port") {
|
||||
set_hddtemp_port(value);
|
||||
}
|
||||
#endif /* HDDTEMP */
|
||||
CONF("pad_percents") {
|
||||
pad_percents = atoi(value);
|
||||
}
|
||||
|
@ -41,11 +41,9 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
#define BUFLEN 512
|
||||
#define DEFAULT_PORT "7634"
|
||||
#define DEFAULT_HOST "127.0.0.1"
|
||||
|
||||
static char *hddtemp_host = NULL;
|
||||
static char *hddtemp_port = NULL;
|
||||
static conky::simple_config_setting<std::string> hddtemp_host("hddtemp_host", "localhost", false);
|
||||
static conky::simple_config_setting<std::string> hddtemp_port("hddtemp_port", "7634", false);
|
||||
|
||||
struct hdd_info {
|
||||
hdd_info() : next(0) {}
|
||||
@ -57,18 +55,6 @@ struct hdd_info {
|
||||
|
||||
struct hdd_info hdd_info_head;
|
||||
|
||||
void set_hddtemp_host(const char *host)
|
||||
{
|
||||
free_and_zero(hddtemp_host);
|
||||
hddtemp_host = strdup(host);
|
||||
}
|
||||
|
||||
void set_hddtemp_port(const char *port)
|
||||
{
|
||||
free_and_zero(hddtemp_port);
|
||||
hddtemp_port = strdup(port);
|
||||
}
|
||||
|
||||
static void __free_hddtemp_info(struct hdd_info *hdi)
|
||||
{
|
||||
if (hdi->next)
|
||||
@ -104,20 +90,17 @@ static void add_hddtemp_info(char *dev, short temp, char unit)
|
||||
static char *fetch_hddtemp_output(void)
|
||||
{
|
||||
int sockfd;
|
||||
const char *dst_host, *dst_port;
|
||||
char *buf = NULL;
|
||||
int buflen, offset = 0, rlen;
|
||||
struct addrinfo hints, *result, *rp;
|
||||
int i;
|
||||
|
||||
dst_host = hddtemp_host ? hddtemp_host : DEFAULT_HOST;
|
||||
dst_port = hddtemp_port ? hddtemp_port : DEFAULT_PORT;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_INET; /* XXX: hddtemp has no ipv6 support (yet?) */
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if ((i = getaddrinfo(dst_host, dst_port, &hints, &result))) {
|
||||
if ((i = getaddrinfo(hddtemp_host.get(*state).c_str(),
|
||||
hddtemp_port.get(*state).c_str(), &hints, &result))) {
|
||||
NORM_ERR("getaddrinfo(): %s", gai_strerror(i));
|
||||
return NULL;
|
||||
}
|
||||
@ -236,8 +219,6 @@ int update_hddtemp(void) {
|
||||
void free_hddtemp(struct text_object *obj)
|
||||
{
|
||||
free_hddtemp_info();
|
||||
free_and_zero(hddtemp_host);
|
||||
free_and_zero(hddtemp_port);
|
||||
free_and_zero(obj->data.s);
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
#ifndef HDDTEMP_H_
|
||||
#define HDDTEMP_H_
|
||||
|
||||
void set_hddtemp_host(const char *);
|
||||
void set_hddtemp_port(const char *);
|
||||
int update_hddtemp(void);
|
||||
void free_hddtemp(struct text_object *);
|
||||
void print_hddtemp(struct text_object *, char *, int);
|
||||
|
Loading…
Reference in New Issue
Block a user