diff --git a/src/conky.c b/src/conky.c index 44472e69..02f2d495 100644 --- a/src/conky.c +++ b/src/conky.c @@ -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); } diff --git a/src/core.c b/src/core.c index 2d68c368..a26fa638 100644 --- a/src/core.c +++ b/src/core.c @@ -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; diff --git a/src/linux.c b/src/linux.c index 6298fc3e..60c29cd9 100644 --- a/src/linux.c +++ b/src/linux.c @@ -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: diff --git a/src/linux.h b/src/linux.h index 7cb26165..0a560882 100644 --- a/src/linux.h +++ b/src/linux.h @@ -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);