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_END()
};
+ cfg_opt_t path_exists_opts[] = {
+ CFG_STR("path", NULL, CFGF_NONE),
+ CFG_STR("format", "%title: %status", CFGF_NONE),
+ CFG_CUSTOM_COLOR_OPTS,
+ CFG_END()
+ };
+
cfg_opt_t wireless_opts[] = {
CFG_STR("format_up", "W: (%quality at %essid, %bitrate) %ip", CFGF_NONE),
CFG_STR("format_down", "W: down", CFGF_NONE),
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 load_opts[] = {
CFG_STR("format", "%1min %5min %15min", CFGF_NONE),
- CFG_INT("max_threshold", 5, CFGF_NONE),
+ CFG_FLOAT("max_threshold", 5, 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()
};
cfg_opt_t volume_opts[] = {
CFG_STR("format", "♪: %volume", CFGF_NONE),
+ CFG_STR("format_muted", "♪: 0%%", CFGF_NONE),
CFG_STR("device", "default", CFGF_NONE),
CFG_STR("mixer", "Master", CFGF_NONE),
CFG_INT("mixer_idx", 0, CFGF_NONE),
CFG_STR_LIST("order", "{}", CFGF_NONE),
CFG_SEC("general", general_opts, CFGF_NONE),
CFG_SEC("run_watch", run_watch_opts, CFGF_TITLE | CFGF_MULTI),
+ CFG_SEC("path_exists", path_exists_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("wireless", wireless_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("ethernet", ethernet_opts, CFGF_TITLE | CFGF_MULTI),
CFG_SEC("battery", battery_opts, CFGF_TITLE | CFGF_MULTI),
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"))
if (output_format == O_I3BAR)
yajl_gen_array_open(json_gen);
else if (output_format == O_TERM)
- /* Restore the cursor-position */
- printf("\033[u");
+ /* Restore the cursor-position, clear line */
+ 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;
}
SEC_CLOSE_MAP;
}
+ CASE_SEC_TITLE("path_exists") {
+ SEC_OPEN_MAP("path_exists");
+ print_path_exists(json_gen, buffer, title, cfg_getstr(sec, "path"), cfg_getstr(sec, "format"));
+ 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;
}
CASE_SEC("load") {
SEC_OPEN_MAP("load");
- print_load(json_gen, buffer, cfg_getstr(sec, "format"), cfg_getint(sec, "max_threshold"));
+ print_load(json_gen, buffer, cfg_getstr(sec, "format"), cfg_getfloat(sec, "max_threshold"));
SEC_CLOSE_MAP;
}
CASE_SEC_TITLE("volume") {
SEC_OPEN_MAP("volume");
print_volume(json_gen, buffer, cfg_getstr(sec, "format"),
+ cfg_getstr(sec, "format_muted"),
cfg_getstr(sec, "device"),
cfg_getstr(sec, "mixer"),
cfg_getint(sec, "mixer_idx"));