diff --git a/src/common.c b/src/common.c index 8c5c1d12..cfd806f2 100644 --- a/src/common.c +++ b/src/common.c @@ -709,3 +709,37 @@ void print_freq_g(struct text_object *obj, char *p, int p_max_size) #endif /* __OpenBSD */ } } + +#ifndef __OpenBSD__ +void print_acpifan(struct text_object *obj, char *p, int p_max_size) +{ + (void)obj; + get_acpi_fan(p, p_max_size); +} + +void print_acpiacadapter(struct text_object *obj, char *p, int p_max_size) +{ + (void)obj; + get_acpi_ac_adapter(p, p_max_size); +} + +void print_battery(struct text_object *obj, char *p, int p_max_size) +{ + get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_STATUS); +} + +void print_battery_time(struct text_object *obj, char *p, int p_max_size) +{ + get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_TIME); +} + +uint8_t battery_percentage(struct text_object *obj) +{ + return get_battery_perct(obj->data.s); +} + +void print_battery_short(struct text_object *obj, char *p, int p_max_size) +{ + get_battery_short_status(p, p_max_size, obj->data.s); +} +#endif /* !__OpenBSD__ */ diff --git a/src/common.h b/src/common.h index 21d60cf1..a4f86e78 100644 --- a/src/common.h +++ b/src/common.h @@ -116,4 +116,13 @@ void free_acpitemp(struct text_object *); void print_freq(struct text_object *, char *, int); void print_freq_g(struct text_object *, char *, int); +#ifndef __OpenBSD__ +void print_acpifan(struct text_object *, char *, int); +void print_acpiacadapter(struct text_object *, char *, int); +void print_battery(struct text_object *, char *, int); +void print_battery_time(struct text_object *, char *, int); +uint8_t battery_percentage(struct text_object *); +void print_battery_short(struct text_object *, char *, int); +#endif /* !__OpenBSD__ */ + #endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index 45ea63c3..ee8cdc8f 100644 --- a/src/conky.c +++ b/src/conky.c @@ -798,27 +798,6 @@ void generate_text_internal(char *p, int p_max_size, switch (obj->type) { default: NORM_ERR("not implemented obj type %d", obj->type); -#ifndef __OpenBSD__ - OBJ(acpifan) { - get_acpi_fan(p, p_max_size); - } - OBJ(acpiacadapter) { - get_acpi_ac_adapter(p, p_max_size); - } - OBJ(battery) { - get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_STATUS); - } - OBJ(battery_time) { - get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_TIME); - } - OBJ(battery_percent) { - percent_print(p, p_max_size, get_battery_perct(obj->data.s)); - } - OBJ(battery_short) { - get_battery_short_status(p, p_max_size, obj->data.s); - } -#endif /* __OpenBSD__ */ - #ifdef X11 OBJ(font) { new_font(p, obj->data.s); diff --git a/src/core.c b/src/core.c index b137056e..b4e779cb 100644 --- a/src/core.c +++ b/src/core.c @@ -164,6 +164,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->callbacks.print = &print_acpitemp; obj->callbacks.free = &free_acpitemp; END OBJ(acpiacadapter, 0) + obj->callbacks.print = &print_acpiacadapter; END OBJ(freq, 0) #endif /* !__OpenBSD__ */ get_cpu_count(); @@ -246,6 +247,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long #ifndef __OpenBSD__ END OBJ(acpifan, 0) + obj->callbacks.print = &print_acpifan; END OBJ(battery, 0) char bat[64]; @@ -255,6 +257,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long strcpy(bat, "BAT0"); } obj->data.s = strndup(bat, text_buffer_size); + obj->callbacks.print = &print_battery; obj->callbacks.free = &gen_free_opaque; END OBJ(battery_short, 0) char bat[64]; @@ -265,6 +268,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long strcpy(bat, "BAT0"); } obj->data.s = strndup(bat, text_buffer_size); + obj->callbacks.print = &print_battery_short; obj->callbacks.free = &gen_free_opaque; END OBJ(battery_time, 0) char bat[64]; @@ -275,6 +279,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long strcpy(bat, "BAT0"); } obj->data.s = strndup(bat, text_buffer_size); + obj->callbacks.print = &print_battery_time; obj->callbacks.free = &gen_free_opaque; END OBJ(battery_percent, 0) char bat[64]; @@ -285,6 +290,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long strcpy(bat, "BAT0"); } obj->data.s = strndup(bat, text_buffer_size); + obj->callbacks.percentage = &battery_percentage; obj->callbacks.free = &gen_free_opaque; END OBJ(battery_bar, 0) char bat[64];