diff --git a/src/conky.c b/src/conky.c index 549e0b32..5dc9b33f 100644 --- a/src/conky.c +++ b/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]; diff --git a/src/core.c b/src/core.c index 3fe685d4..ab86b128 100644 --- a/src/core.c +++ b/src/core.c @@ -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); diff --git a/src/smapi.c b/src/smapi.c index a3817f74..1fc5758d 100644 --- a/src/smapi.c +++ b/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; +} diff --git a/src/smapi.h b/src/smapi.h index 74a73578..32b2ea91 100644 --- a/src/smapi.h +++ b/src/smapi.h @@ -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 */