summaryrefslogtreecommitdiff
path: root/i3status.c
diff options
context:
space:
mode:
authorFelix Buehler <account@buehler.rocks>2018-03-20 15:35:28 +0100
committerFelix Buehler <account@buehler.rocks>2018-04-11 22:36:41 +0200
commitc55754542ec8f17246415fa19baf06ef7dc6ab87 (patch)
treefb734f43ae9c84e6a3697f9864be15753b65548c /i3status.c
parent2cb0ffa01aa684f8664ba38fa9ef0df90eed2385 (diff)
Implement support for memory-usage on Linux
Diffstat (limited to 'i3status.c')
-rw-r--r--i3status.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/i3status.c b/i3status.c
index 5088c96..6232808 100644
--- a/i3status.c
+++ b/i3status.c
@@ -421,6 +421,22 @@ int main(int argc, char *argv[]) {
CFG_CUSTOM_SEP_BLOCK_WIDTH_OPT,
CFG_END()};
+ cfg_opt_t memory_opts[] = {
+ CFG_STR("format", "%used %free %available", CFGF_NONE),
+ CFG_STR("degraded_format_below_threshold", NULL, CFGF_NONE),
+ CFG_STR("degraded_threshold_type", "percentage_avail", CFGF_NONE),
+ CFG_FLOAT("degraded_low_threshold", 0, CFGF_NONE),
+ CFG_STR("critical_format_below_threshold", NULL, CFGF_NONE),
+ CFG_STR("critical_threshold_type", "percentage_avail", CFGF_NONE),
+ CFG_FLOAT("critical_low_threshold", 0, CFGF_NONE),
+ CFG_BOOL("use_available_memory", true, CFGF_NONE),
+ CFG_CUSTOM_ALIGN_OPT,
+ CFG_CUSTOM_COLOR_OPTS,
+ CFG_CUSTOM_MIN_WIDTH_OPT,
+ CFG_CUSTOM_SEPARATOR_OPT,
+ CFG_CUSTOM_SEP_BLOCK_WIDTH_OPT,
+ CFG_END()};
+
cfg_opt_t usage_opts[] = {
CFG_STR("format", "%usage", CFGF_NONE),
CFG_STR("format_above_threshold", NULL, CFGF_NONE),
@@ -490,6 +506,7 @@ int main(int argc, char *argv[]) {
CFG_SEC("tztime", tztime_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("ddate", ddate_opts, CFGF_NONE),
CFG_SEC("load", load_opts, CFGF_NONE),
+ CFG_SEC("memory", memory_opts, CFGF_NONE),
CFG_SEC("cpu_usage", usage_opts, CFGF_NONE),
CFG_END()};
@@ -724,6 +741,12 @@ int main(int argc, char *argv[]) {
SEC_CLOSE_MAP;
}
+ CASE_SEC("memory") {
+ SEC_OPEN_MAP("memory");
+ print_memory(json_gen, buffer, cfg_getstr(sec, "format"), cfg_getstr(sec, "degraded_format_below_threshold"), cfg_getstr(sec, "degraded_threshold_type"), cfg_getfloat(sec, "degraded_low_threshold"), cfg_getstr(sec, "critical_format_below_threshold"), cfg_getstr(sec, "critical_threshold_type"), cfg_getfloat(sec, "critical_low_threshold"), cfg_getbool(sec, "use_available_memory"));
+ SEC_CLOSE_MAP;
+ }
+
CASE_SEC("time") {
SEC_OPEN_MAP("time");
print_time(json_gen, buffer, NULL, cfg_getstr(sec, "format"), NULL, NULL, NULL, tv.tv_sec);