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"),
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_seperator(separator);
const char *current = cfg_getnstr(cfg, "order", j);
#define SEC_CLOSE_MAP \
do { \
if (output_format == O_I3BAR) { \
+ const char *_sep = cfg_getstr(cfg_general, "separator"); \
+ if (strlen(_sep) == 0) {\
+ yajl_gen_string(json_gen, (const unsigned char *)"separator", strlen("separator")); \
+ yajl_gen_bool(json_gen, false); \
+ } \
yajl_gen_map_close(json_gen); \
} \
} while (0)
bool slurp(const char *filename, char *destination, int size);
/* src/output.c */
-void print_seperator();
+void print_seperator(const char *separator);
char *color(const char *colorstr);
char *endcolor() __attribute__ ((pure));
void reset_cursor(void);
should only used for such quick glances, because it will only support very
basic output-features (for example you only get 3 bits of color depth).
none::
-Does not use any color codes. Separates values by the pipe symbol. This should
-be used with i3bar and can be used for custom scripts.
+Does not use any color codes. Separates values by the pipe symbol by default.
+This should be used with i3bar and can be used for custom scripts.
It's also possible to use the color_good, color_degraded, color_bad directives
to define specific colors per module. If one of these directives is defined
in a module section its value will override the value defined in the general
section just for this module.
+If you don't fancy the vertical separators between modules i3status/i3bar
+uses by default, you can employ the +separator+ directive to configure how
+modules are separated. You can either disable the default separator altogether
+setting it to the empty string. You might then define separation as part of a
+module's format string. This is your only option when using the i3bar output
+format as the separator is drawn by i3bar directly otherwise. For the other
+output formats, the provided non-empty string will be automatically enclosed
+with the necessary coloring bits if color support is enabled.
+
+*Example configuration*:
+-------------------------------------------------------------
+general {
+ output_format = "xmobar"
+ separator = " "
+}
+
+order += "load"
+order += "disk /"
+
+load {
+ format = "[ load: %1min, %5min, %15min ]"
+}
+disk "/" {
+ format = "%avail"
+}
+-------------------------------------------------------------
+
=== IPv6
This module gets the IPv6 address used for outgoing connections (that is, the
else return "";
}
-void print_seperator(void) {
+void print_seperator(const char *separator) {
+ if (output_format == O_I3BAR || strlen(separator) == 0)
+ return;
+
if (output_format == O_DZEN2)
- printf("^fg(%s)^p(5;-2)^ro(2)^p()^fg()^p(5)", cfg_getstr(cfg_general, "color_separator"));
+ printf("^fg(%s)%s^fg()", cfg_getstr(cfg_general, "color_separator"), separator);
else if (output_format == O_XMOBAR)
- printf("<fc=%s> | </fc>", cfg_getstr(cfg_general, "color_separator"));
+ printf("<fc=%s>%s</fc>", cfg_getstr(cfg_general, "color_separator"), separator);
else if (output_format == O_TERM)
- printf(" %s|%s ", color("color_separator"), endcolor());
+ printf("%s%s%s", color("color_separator"), separator, endcolor());
else if (output_format == O_NONE)
- printf(" | ");
+ printf("%s", separator);
}
/*