1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-17 18:45:10 +00:00

ibm: put specific code to where it belongs

This commit is contained in:
Phil Sutter 2009-10-13 23:01:31 +02:00
parent 7fc1c801aa
commit 2631f42820
4 changed files with 24 additions and 19 deletions

View File

@ -1343,9 +1343,7 @@ static void generate_text_internal(char *p, int p_max_size,
get_ibm_acpi_fan(p, p_max_size);
}
OBJ(ibm_temps) {
get_ibm_acpi_temps();
temp_print(p, p_max_size,
ibm_acpi.temps[obj->data.sensor], TEMP_CELSIUS);
print_ibm_temps(obj, p, p_max_size);
}
OBJ(ibm_volume) {
get_ibm_acpi_volume(p, p_max_size);

View File

@ -355,13 +355,8 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
END OBJ(i8k_buttons_status, &update_i8k)
#if defined(IBM)
END OBJ(ibm_fan, 0)
END OBJ(ibm_temps, 0, "ibm_temps: needs an argument")
if (!isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) >= 8) {
obj->data.sensor = 0;
NORM_ERR("Invalid temperature sensor! Sensor number must be 0 to 7. "
"Using 0 (CPU temp sensor).");
} else
obj->data.sensor = atoi(&arg[0]);
END OBJ(ibm_temps, &get_ibm_acpi_temps, "ibm_temps: needs an argument")
parse_ibm_temps_arg(obj, arg);
END OBJ(ibm_volume, 0)
END OBJ(ibm_brightness, 0)
#endif

View File

@ -38,6 +38,8 @@
#include <string.h>
#include <stdlib.h>
static int ibm_acpi_temps[8];
/* Here come the IBM ACPI-specific things. For reference, see
* http://ibm-acpi.sourceforge.net/README
* If IBM ACPI is installed, /proc/acpi/ibm contains the following files:
@ -151,9 +153,9 @@ void get_ibm_acpi_temps(void)
break;
}
if (sscanf(line, "temperatures: %d %d %d %d %d %d %d %d",
&ibm_acpi.temps[0], &ibm_acpi.temps[1], &ibm_acpi.temps[2],
&ibm_acpi.temps[3], &ibm_acpi.temps[4], &ibm_acpi.temps[5],
&ibm_acpi.temps[6], &ibm_acpi.temps[7])) {
&ibm_acpi_temps[0], &ibm_acpi_temps[1], &ibm_acpi_temps[2],
&ibm_acpi_temps[3], &ibm_acpi_temps[4], &ibm_acpi_temps[5],
&ibm_acpi_temps[6], &ibm_acpi_temps[7])) {
break;
}
}
@ -264,3 +266,17 @@ void get_ibm_acpi_brightness(char *p_client_buffer, size_t client_buffer_size)
snprintf(p_client_buffer, client_buffer_size, "%d", brightness);
}
void parse_ibm_temps_arg(struct text_object *obj, const char *arg)
{
if (!isdigit(arg[0]) || strlen(arg) > 1 || atoi(&arg[0]) >= 8) {
obj->data.sensor = 0;
NORM_ERR("Invalid temperature sensor! Sensor number must be 0 to 7. "
"Using 0 (CPU temp sensor).");
} else
obj->data.sensor = atoi(arg);
}
void print_ibm_temps(struct text_object *obj, char *p, int p_max_size)
{
temp_print(p, p_max_size, ibm_acpi_temps[obj->data.sensor], TEMP_CELSIUS);
}

View File

@ -5,15 +5,11 @@
#include <sys/types.h>
struct ibm_acpi_struct {
int temps[8];
};
struct ibm_acpi_struct ibm_acpi;
void get_ibm_acpi_fan(char *buf, size_t client_buffer_size);
void get_ibm_acpi_temps(void);
void get_ibm_acpi_volume(char *buf, size_t client_buffer_size);
void get_ibm_acpi_brightness(char *buf, size_t client_buffer_size);
void parse_ibm_temps_arg(struct text_object *, const char *);
void print_ibm_temps(struct text_object *, char *, int);
#endif /* _IBM_H */