1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

convert pb_battery to callbacks.print

This commit is contained in:
Phil Sutter 2009-11-16 01:20:35 +01:00
parent 3f83bd34f4
commit 60ad080d1d
4 changed files with 5 additions and 7 deletions

View File

@ -907,9 +907,6 @@ void generate_text_internal(char *p, int p_max_size,
DO_JUMP;
}
}
OBJ(pb_battery) {
get_powerbook_batt_info(p, p_max_size, obj->data.i);
}
#endif /* __linux__ */
#if (defined(__FreeBSD__) || defined(__linux__))
OBJ(if_up) {

View File

@ -348,6 +348,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
NORM_ERR("pb_battery: illegal argument '%s', defaulting to status", arg);
obj->data.i = PB_BATT_STATUS;
}
obj->callbacks.print = get_powerbook_batt_info;
#endif /* __linux__ */
#if (defined(__FreeBSD__) || defined(__linux__))
END OBJ_IF_ARG(if_up, 0, "if_up needs an argument")

View File

@ -2081,7 +2081,7 @@ static char pb_battery_info[3][32];
static double pb_battery_info_update;
#define PMU_PATH "/proc/pmu"
void get_powerbook_batt_info(char *buffer, size_t n, int i)
void get_powerbook_batt_info(struct text_object *obj, char *buffer, int n)
{
static int rep = 0;
const char *batt_path = PMU_PATH "/battery_0";
@ -2092,7 +2092,7 @@ void get_powerbook_batt_info(char *buffer, size_t n, int i)
/* don't update battery too often */
if (current_update_time - pb_battery_info_update < 29.5) {
snprintf(buffer, n, "%s", pb_battery_info[i]);
snprintf(buffer, n, "%s", pb_battery_info[obj->data.i]);
return;
}
pb_battery_info_update = current_update_time;
@ -2182,7 +2182,7 @@ void get_powerbook_batt_info(char *buffer, size_t n, int i)
sizeof(pb_battery_info[PB_BATT_TIME]), timeval);
}
snprintf(buffer, n, "%s", pb_battery_info[i]);
snprintf(buffer, n, "%s", pb_battery_info[obj->data.i]);
}
void update_top(void)

View File

@ -17,7 +17,7 @@ void print_gateway_iface(struct text_object *, char *, int);
void print_gateway_ip(struct text_object *, char *, int);
enum { PB_BATT_STATUS, PB_BATT_PERCENT, PB_BATT_TIME };
void get_powerbook_batt_info(char *, size_t, int);
void get_powerbook_batt_info(struct text_object *, char *, int);
void parse_i2c_sensor(struct text_object *, const char *);
void parse_hwmon_sensor(struct text_object *, const char *);