mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-15 19:56:55 +00:00
convert some non-openbsd objects to callbacks.{print,iftest}
This commit is contained in:
parent
c652427aed
commit
3fa5c55933
34
src/common.c
34
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__ */
|
||||
|
@ -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 */
|
||||
|
21
src/conky.c
21
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);
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user