diff --git a/doc/variables.xml b/doc/variables.xml index b55da7b9..a5f2b561 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -2032,6 +2032,15 @@ Bar that shows amount of memory in use (including memory used by system buffers and caches) + + + + + + + Amount of "dirty" memory (linux only) + + diff --git a/src/common.cc b/src/common.cc index d4fe02e0..98bbf58a 100644 --- a/src/common.cc +++ b/src/common.cc @@ -526,6 +526,7 @@ PRINT_HR_GENERATOR(memwithbuffers) PRINT_HR_GENERATOR(memeasyfree) PRINT_HR_GENERATOR(memfree) PRINT_HR_GENERATOR(memmax) +PRINT_HR_GENERATOR(memdirty) PRINT_HR_GENERATOR(swap) PRINT_HR_GENERATOR(swapfree) PRINT_HR_GENERATOR(swapmax) diff --git a/src/common.h b/src/common.h index 55f301d5..2fad9776 100644 --- a/src/common.h +++ b/src/common.h @@ -107,6 +107,7 @@ void print_memwithbuffers(struct text_object *, char *, int); void print_memeasyfree(struct text_object *, char *, int); void print_memfree(struct text_object *, char *, int); void print_memmax(struct text_object *, char *, int); +void print_memdirty(struct text_object *, char *, int); void print_swap(struct text_object *, char *, int); void print_swapfree(struct text_object *, char *, int); void print_swapmax(struct text_object *, char *, int); diff --git a/src/conky.h b/src/conky.h index de29d871..b27bab45 100644 --- a/src/conky.h +++ b/src/conky.h @@ -196,7 +196,7 @@ struct information { double uptime; /* memory information in kilobytes */ - unsigned long long mem, memwithbuffers, memeasyfree, memfree, memmax; + unsigned long long mem, memwithbuffers, memeasyfree, memfree, memmax, memdirty; unsigned long long swap, swapfree, swapmax; unsigned long long bufmem, buffers, cached; diff --git a/src/core.cc b/src/core.cc index 41b6c094..1ead4200 100644 --- a/src/core.cc +++ b/src/core.cc @@ -985,6 +985,10 @@ struct text_object *construct_text_object(char *s, const char *arg, long obj->callbacks.print = &print_memmax; END OBJ(memperc, &update_meminfo) obj->callbacks.percentage = &mem_percentage; +#ifdef __linux__ + END OBJ(memdirty, &update_meminfo) + obj->callbacks.print = &print_memdirty; +#endif #ifdef BUILD_X11 END OBJ(memgauge, &update_meminfo) scan_gauge(obj, arg, 1); diff --git a/src/linux.cc b/src/linux.cc index e0929204..b5ff75a3 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -165,7 +165,7 @@ int update_meminfo(void) /* unsigned int a; */ char buf[256]; - info.mem = info.memwithbuffers = info.memmax = info.swap = info.swapfree = info.swapmax = + info.mem = info.memwithbuffers = info.memmax = info.memdirty = info.swap = info.swapfree = info.swapmax = info.bufmem = info.buffers = info.cached = info.memfree = info.memeasyfree = 0; if (!(meminfo_fp = open_file("/proc/meminfo", &rep))) { @@ -189,6 +189,8 @@ int update_meminfo(void) sscanf(buf, "%*s %llu", &info.buffers); } else if (strncmp(buf, "Cached:", 7) == 0) { sscanf(buf, "%*s %llu", &info.cached); + } else if (strncmp(buf, "Dirty:", 6) == 0) { + sscanf(buf, "%*s %llu", &info.memdirty); } }