1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-16 04:02:15 +00:00

convert some non-openbsd objects to callbacks.{print,iftest}

This commit is contained in:
Phil Sutter 2009-11-26 01:51:41 +01:00
parent c652427aed
commit 3fa5c55933
4 changed files with 49 additions and 21 deletions

View File

@ -709,3 +709,37 @@ void print_freq_g(struct text_object *obj, char *p, int p_max_size)
#endif /* __OpenBSD */ #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__ */

View File

@ -116,4 +116,13 @@ void free_acpitemp(struct text_object *);
void print_freq(struct text_object *, char *, int); void print_freq(struct text_object *, char *, int);
void print_freq_g(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 */ #endif /* _COMMON_H */

View File

@ -798,27 +798,6 @@ void generate_text_internal(char *p, int p_max_size,
switch (obj->type) { switch (obj->type) {
default: default:
NORM_ERR("not implemented obj type %d", obj->type); 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 #ifdef X11
OBJ(font) { OBJ(font) {
new_font(p, obj->data.s); new_font(p, obj->data.s);

View File

@ -164,6 +164,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
obj->callbacks.print = &print_acpitemp; obj->callbacks.print = &print_acpitemp;
obj->callbacks.free = &free_acpitemp; obj->callbacks.free = &free_acpitemp;
END OBJ(acpiacadapter, 0) END OBJ(acpiacadapter, 0)
obj->callbacks.print = &print_acpiacadapter;
END OBJ(freq, 0) END OBJ(freq, 0)
#endif /* !__OpenBSD__ */ #endif /* !__OpenBSD__ */
get_cpu_count(); get_cpu_count();
@ -246,6 +247,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
#ifndef __OpenBSD__ #ifndef __OpenBSD__
END OBJ(acpifan, 0) END OBJ(acpifan, 0)
obj->callbacks.print = &print_acpifan;
END OBJ(battery, 0) END OBJ(battery, 0)
char bat[64]; char bat[64];
@ -255,6 +257,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
strcpy(bat, "BAT0"); strcpy(bat, "BAT0");
} }
obj->data.s = strndup(bat, text_buffer_size); obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.print = &print_battery;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
END OBJ(battery_short, 0) END OBJ(battery_short, 0)
char bat[64]; char bat[64];
@ -265,6 +268,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
strcpy(bat, "BAT0"); strcpy(bat, "BAT0");
} }
obj->data.s = strndup(bat, text_buffer_size); obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.print = &print_battery_short;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
END OBJ(battery_time, 0) END OBJ(battery_time, 0)
char bat[64]; char bat[64];
@ -275,6 +279,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
strcpy(bat, "BAT0"); strcpy(bat, "BAT0");
} }
obj->data.s = strndup(bat, text_buffer_size); obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.print = &print_battery_time;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
END OBJ(battery_percent, 0) END OBJ(battery_percent, 0)
char bat[64]; char bat[64];
@ -285,6 +290,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
strcpy(bat, "BAT0"); strcpy(bat, "BAT0");
} }
obj->data.s = strndup(bat, text_buffer_size); obj->data.s = strndup(bat, text_buffer_size);
obj->callbacks.percentage = &battery_percentage;
obj->callbacks.free = &gen_free_opaque; obj->callbacks.free = &gen_free_opaque;
END OBJ(battery_bar, 0) END OBJ(battery_bar, 0)
char bat[64]; char bat[64];