mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 17:47:09 +00:00
convert laptop_mode to callbacks.print
This commit is contained in:
parent
f3cafc6a7c
commit
3f83bd34f4
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
11
src/linux.c
11
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:
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user