mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-16 01:57:09 +00:00
Add ${battery_status} variable to display the battery status
This commit is contained in:
parent
0bc7b80d78
commit
d963e0e418
@ -638,6 +638,25 @@ uint8_t battery_percentage(struct text_object *obj) {
|
|||||||
void print_battery_short(struct text_object *obj, char *p, unsigned int p_max_size) {
|
void print_battery_short(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||||
get_battery_short_status(p, p_max_size, obj->data.s);
|
get_battery_short_status(p, p_max_size, obj->data.s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_battery_status(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||||
|
get_battery_stuff(p, p_max_size, obj->data.s, BATTERY_STATUS);
|
||||||
|
if (0 == strncmp("charging", p, 8)) {
|
||||||
|
snprintf(p, p_max_size, "%s", "charging");
|
||||||
|
} else if (0 == strncmp("discharging", p, 11) ||
|
||||||
|
0 == strncmp("remaining", p, 9)) {
|
||||||
|
snprintf(p, p_max_size, "%s", "discharging");
|
||||||
|
} else if (0 == strncmp("charged", p, 7)) {
|
||||||
|
snprintf(p, p_max_size, "%s", "charged");
|
||||||
|
} else if (0 == strncmp("not present", p, 11) ||
|
||||||
|
0 == strncmp("absent/on AC", p, 12)) {
|
||||||
|
snprintf(p, p_max_size, "%s", "not present");
|
||||||
|
} else if (0 == strncmp("empty", p, 5)) {
|
||||||
|
snprintf(p, p_max_size, "%s", "empty");
|
||||||
|
} else if (0 == strncmp("unknown", p, 7)) {
|
||||||
|
snprintf(p, p_max_size, "%s", "unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
|
|
||||||
void print_blink(struct text_object *obj, char *p, unsigned int p_max_size) {
|
void print_blink(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||||
|
@ -158,6 +158,7 @@ void print_battery(struct text_object *, char *, unsigned int);
|
|||||||
void print_battery_time(struct text_object *, char *, unsigned int);
|
void print_battery_time(struct text_object *, char *, unsigned int);
|
||||||
uint8_t battery_percentage(struct text_object *);
|
uint8_t battery_percentage(struct text_object *);
|
||||||
void print_battery_short(struct text_object *, char *, unsigned int);
|
void print_battery_short(struct text_object *, char *, unsigned int);
|
||||||
|
void print_battery_status(struct text_object *, char *, unsigned int);
|
||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
|
|
||||||
void free_cpu(struct text_object *);
|
void free_cpu(struct text_object *);
|
||||||
|
@ -545,6 +545,10 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
||||||
obj->callbacks.print = &print_battery_short;
|
obj->callbacks.print = &print_battery_short;
|
||||||
obj->callbacks.free = &gen_free_opaque;
|
obj->callbacks.free = &gen_free_opaque;
|
||||||
|
|
||||||
|
END OBJ(battery_status, 0) obj->data.s = strndup(arg ? arg : "BAT0", text_buffer_size.get(*state));
|
||||||
|
obj->callbacks.print = &print_battery_status;
|
||||||
|
obj->callbacks.free = &gen_free_opaque;
|
||||||
END OBJ(battery_time, nullptr) char bat[64];
|
END OBJ(battery_time, nullptr) char bat[64];
|
||||||
|
|
||||||
if (arg != nullptr) {
|
if (arg != nullptr) {
|
||||||
|
@ -39,6 +39,7 @@ int gateway_exists(struct text_object *);
|
|||||||
void print_gateway_iface(struct text_object *, char *, unsigned int);
|
void print_gateway_iface(struct text_object *, char *, unsigned int);
|
||||||
void print_gateway_iface2(struct text_object *, char *, unsigned int);
|
void print_gateway_iface2(struct text_object *, char *, unsigned int);
|
||||||
void print_gateway_ip(struct text_object *, char *, unsigned int);
|
void print_gateway_ip(struct text_object *, char *, unsigned int);
|
||||||
|
void print_battery_status(struct text_object *, char *, unsigned int);
|
||||||
|
|
||||||
enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
|
enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
|
||||||
void get_powerbook_batt_info(struct text_object *, char *, unsigned int);
|
void get_powerbook_batt_info(struct text_object *, char *, unsigned int);
|
||||||
|
Loading…
Reference in New Issue
Block a user