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

convert laptop_mode to callbacks.print

This commit is contained in:
Phil Sutter 2009-11-16 01:15:39 +01:00
parent f3cafc6a7c
commit 3f83bd34f4
4 changed files with 9 additions and 8 deletions

View File

@ -907,9 +907,6 @@ void generate_text_internal(char *p, int p_max_size,
DO_JUMP;
}
}
OBJ(laptop_mode) {
snprintf(p, p_max_size, "%d", get_laptop_mode());
}
OBJ(pb_battery) {
get_powerbook_batt_info(p, p_max_size, obj->data.i);
}

View File

@ -336,6 +336,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
obj->data.s = strndup(dev_name(arg), text_buffer_size);
obj->callbacks.free = &gen_free_opaque;
END OBJ(laptop_mode, 0)
obj->callbacks.print = &print_laptop_mode;
END OBJ_ARG(pb_battery, 0, "pb_battery: needs one argument: status, percent or time")
if (strcmp(arg, "status") == EQUAL) {
obj->data.i = PB_BATT_STATUS;

View File

@ -196,15 +196,18 @@ void update_meminfo(void)
fclose(meminfo_fp);
}
int get_laptop_mode(void)
void print_laptop_mode(struct text_object *obj, char *p, int p_max_size)
{
FILE *fp;
int val = -1;
if ((fp = fopen("/proc/sys/vm/laptop_mode", "r")) != NULL)
(void)obj;
if ((fp = fopen("/proc/sys/vm/laptop_mode", "r")) != NULL) {
fscanf(fp, "%d\n", &val);
fclose(fp);
return val;
fclose(fp);
}
snprintf(p, p_max_size, "%d", val);
}
/* my system says:

View File

@ -8,7 +8,7 @@
const char *get_disk_protect_queue(const char *);
char *get_ioscheduler(char *);
int get_laptop_mode(void);
void print_laptop_mode(struct text_object *, char *, int);
void update_gateway_info(void);
void free_gateway_info(void);