return NULL;
}
+/*
+ * Returns the default separator to use if no custom separator has been specified.
+ */
+static char *get_default_separator() {
+ if (output_format == O_DZEN2)
+ return "^p(5;-2)^ro(2)^p()^p(5)";
+ if (output_format == O_I3BAR)
+ // anything besides the empty string indicates that the default separator should be used
+ return "default";
+ return " | ";
+}
+
int main(int argc, char *argv[]) {
unsigned int j;
cfg_opt_t general_opts[] = {
CFG_STR("output_format", "auto", CFGF_NONE),
CFG_BOOL("colors", 1, CFGF_NONE),
+ CFG_STR("separator", "default", CFGF_NONE),
CFG_STR("color_separator", "#333333", CFGF_NONE),
CFG_INT("interval", 1, CFGF_NONE),
CFG_COLOR_OPTS("#00FF00", "#FFFF00", "#FF0000"),
CFG_STR("threshold_type", "time", CFGF_NONE),
CFG_BOOL("last_full_capacity", false, CFGF_NONE),
CFG_BOOL("integer_battery_capacity", false, CFGF_NONE),
+ CFG_BOOL("hide_seconds", false, CFGF_NONE),
CFG_CUSTOM_COLOR_OPTS,
CFG_END()
};
cfg_opt_t disk_opts[] = {
CFG_STR("format", "%free", CFGF_NONE),
+ CFG_STR("prefix_type", "binary", CFGF_NONE),
CFG_END()
};
output_format = O_NONE;
else die("Unknown output format: \"%s\"\n", output_str);
+ const char *separator = cfg_getstr(cfg_general, "separator");
+
+ // if no custom separator has been provided, use the default one
+ if (strcasecmp(separator, "default") == 0)
+ separator = get_default_separator();
+
if (!valid_color(cfg_getstr(cfg_general, "color_good"))
|| !valid_color(cfg_getstr(cfg_general, "color_degraded"))
|| !valid_color(cfg_getstr(cfg_general, "color_bad"))
printf("\033[u\033[K");
for (j = 0; j < cfg_size(cfg, "order"); j++) {
if (j > 0)
- print_seperator();
+ print_separator(separator);
const char *current = cfg_getnstr(cfg, "order", j);
CASE_SEC_TITLE("battery") {
SEC_OPEN_MAP("battery");
- print_battery_info(json_gen, buffer, atoi(title), cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getstr(sec, "format_down"), cfg_getint(sec, "low_threshold"), cfg_getstr(sec, "threshold_type"), cfg_getbool(sec, "last_full_capacity"), cfg_getbool(sec, "integer_battery_capacity"));
+ print_battery_info(json_gen, buffer, atoi(title), cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getstr(sec, "format_down"), cfg_getint(sec, "low_threshold"), cfg_getstr(sec, "threshold_type"), cfg_getbool(sec, "last_full_capacity"), cfg_getbool(sec, "integer_battery_capacity"), cfg_getbool(sec, "hide_seconds"));
SEC_CLOSE_MAP;
}
CASE_SEC_TITLE("disk") {
SEC_OPEN_MAP("disk_info");
- print_disk_info(json_gen, buffer, title, cfg_getstr(sec, "format"));
+ print_disk_info(json_gen, buffer, title, cfg_getstr(sec, "format"), cfg_getstr(sec, "prefix_type"));
SEC_CLOSE_MAP;
}