diff options
author | Marco Hunsicker <i3@hunsicker.de> | 2014-03-01 09:55:29 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2014-03-01 10:21:11 +0100 |
commit | 7b021d3eb20c9bf63ad8fa54ae253add47e551f6 (patch) | |
tree | 41e2dec68b86a792082ad6c1ad256627abd73c4a /i3status.c | |
parent | 26faed4c2f2c23f17b0c9170a4a72bb018931ed8 (diff) |
i3status: Allow customization of module separator
This patch adds the ability to customize the separator that is placed
between modules.
Specifically this patch:
* adds the "separator" general directive
* moves the definition of the default separator for the different
output formats (excluding color formatting) to src/i3status.c
* updates the SEC_CLOSE_MAP macro to disable the separator for the
i3bar output format if the separator directive dictates so
* changes print_seperator() in src/output.c to take a separator
parameter in order to disable the output of the separator if
the separator is empty and to use the provided separator
otherwise
* updates the manpage to explain the new directive
Diffstat (limited to 'i3status.c')
-rw-r--r-- | i3status.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -191,12 +191,25 @@ static char *get_config_path(void) { 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"), @@ -403,6 +416,12 @@ int main(int argc, char *argv[]) { 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")) @@ -457,7 +476,7 @@ int main(int argc, char *argv[]) { 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); |