mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 04:06:03 +00:00
convert if_smapi_bat_installed to callbacks.iftest
This commit is contained in:
parent
9887bfdfdf
commit
2dca262c00
11
src/conky.c
11
src/conky.c
@ -1412,17 +1412,6 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
}
|
||||
#endif /* HAVE_ICONV */
|
||||
|
||||
#ifdef IBM
|
||||
OBJ(if_smapi_bat_installed) {
|
||||
int idx;
|
||||
if(obj->data.s && sscanf(obj->data.s, "%i", &idx) == 1) {
|
||||
if(!smapi_bat_installed(idx)) {
|
||||
DO_JUMP;
|
||||
}
|
||||
} else
|
||||
NORM_ERR("argument to if_smapi_bat_installed must be an integer");
|
||||
}
|
||||
#endif /* IBM */
|
||||
OBJ(include) {
|
||||
if(obj->sub) {
|
||||
char buf[max_user_text];
|
||||
|
@ -1067,6 +1067,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
END OBJ_IF_ARG(if_smapi_bat_installed, 0, "if_smapi_bat_installed needs an argument")
|
||||
obj->data.s = strndup(arg, text_buffer_size);
|
||||
obj->callbacks.iftest = &smapi_bat_installed;
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
END OBJ_ARG(smapi_bat_perc, 0, "smapi_bat_perc needs an argument")
|
||||
obj->data.s = strndup(arg, text_buffer_size);
|
||||
|
12
src/smapi.c
12
src/smapi.c
@ -179,3 +179,15 @@ uint8_t smapi_bat_barval(struct text_object *obj)
|
||||
return round_to_int(smapi_get_bat_int(obj->data.i, "remaining_percent") * 2.55);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int smapi_bat_installed(struct text_object *obj)
|
||||
{
|
||||
int idx;
|
||||
if(obj->data.s && sscanf(obj->data.s, "%i", &idx) == 1) {
|
||||
if(!smapi_bat_installed(idx)) {
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
NORM_ERR("argument to if_smapi_bat_installed must be an integer");
|
||||
return 1;
|
||||
}
|
||||
|
@ -41,5 +41,6 @@ uint8_t smapi_bat_percentage(struct text_object *);
|
||||
void print_smapi_bat_temp(struct text_object *, char *, int);
|
||||
void print_smapi_bat_power(struct text_object *, char *, int);
|
||||
uint8_t smapi_bat_barval(struct text_object *);
|
||||
int smapi_bat_installed(struct text_object *obj)
|
||||
|
||||
#endif /* _SMAPI_H */
|
||||
|
Loading…
Reference in New Issue
Block a user