mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 12:10:03 +00:00
voltage: outsource printing code
This commit is contained in:
parent
b25be92273
commit
c8bed3a28d
@ -29,7 +29,8 @@ void update_threads(void);
|
||||
void update_running_processes(void);
|
||||
void update_stuff(void);
|
||||
char get_freq(char *, size_t, const char *, int, unsigned int);
|
||||
char get_voltage(char *, size_t, const char *, int, unsigned int); /* ptarjan */
|
||||
void print_voltage_mv(struct text_object *, char *, int);
|
||||
void print_voltage_v(struct text_object *, char *, int);
|
||||
void update_load_average(void);
|
||||
void update_top(void);
|
||||
void free_all_processes(void);
|
||||
|
12
src/conky.c
12
src/conky.c
@ -818,18 +818,10 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
}
|
||||
#if defined(__linux__)
|
||||
OBJ(voltage_mv) {
|
||||
static int ok = 1;
|
||||
if (ok) {
|
||||
ok = get_voltage(p, p_max_size, "%.0f", 1,
|
||||
obj->data.i);
|
||||
}
|
||||
print_voltage_mv(obj, p, p_max_size);
|
||||
}
|
||||
OBJ(voltage_v) {
|
||||
static int ok = 1;
|
||||
if (ok) {
|
||||
ok = get_voltage(p, p_max_size, "%'.3f", 1000,
|
||||
obj->data.i);
|
||||
}
|
||||
print_voltage_v(obj, p, p_max_size);
|
||||
}
|
||||
|
||||
#ifdef HAVE_IWLIB
|
||||
|
18
src/linux.c
18
src/linux.c
@ -1201,7 +1201,7 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
|
||||
* Peter Tarjan (ptarjan@citromail.hu) */
|
||||
|
||||
/* return cpu voltage in mV (use divisor=1) or V (use divisor=1000) */
|
||||
char get_voltage(char *p_client_buffer, size_t client_buffer_size,
|
||||
static char get_voltage(char *p_client_buffer, size_t client_buffer_size,
|
||||
const char *p_format, int divisor, unsigned int cpu)
|
||||
{
|
||||
FILE *f;
|
||||
@ -1270,6 +1270,22 @@ char get_voltage(char *p_client_buffer, size_t client_buffer_size,
|
||||
return 1;
|
||||
}
|
||||
|
||||
void print_voltage_mv(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
static int ok = 1;
|
||||
if (ok) {
|
||||
ok = get_voltage(p, p_max_size, "%.0f", 1, obj->data.i);
|
||||
}
|
||||
}
|
||||
|
||||
void print_voltage_v(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
static int ok = 1;
|
||||
if (ok) {
|
||||
ok = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.i);
|
||||
}
|
||||
}
|
||||
|
||||
#define ACPI_FAN_DIR "/proc/acpi/fan/"
|
||||
|
||||
void get_acpi_fan(char *p_client_buffer, size_t client_buffer_size)
|
||||
|
Loading…
Reference in New Issue
Block a user