summaryrefslogtreecommitdiff
path: root/include/i3status.h
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@users.noreply.github.com>2016-02-01 08:53:27 +0100
committerMichael Stapelberg <stapelberg@users.noreply.github.com>2016-02-01 08:53:27 +0100
commite073cf496847173913b309a02c3d5578ddf48243 (patch)
tree7fcce456c628987240b0f85f270d46fea76ac64a /include/i3status.h
parent85329802b29406925bf1f1656de85daf892309f3 (diff)
parent6f4819f7a5055e5e3bbfe5ff5b6447d6e300df17 (diff)
Merge pull request #105 from cornerman/issue_104
add separator and separator_block_width as universal module options
Diffstat (limited to 'include/i3status.h')
-rw-r--r--include/i3status.h60
1 files changed, 34 insertions, 26 deletions
diff --git a/include/i3status.h b/include/i3status.h
index a311d24..d6679ae 100644
--- a/include/i3status.h
+++ b/include/i3status.h
@@ -100,32 +100,40 @@ char *pct_mark;
} \
} while (0)
-#define SEC_CLOSE_MAP \
- do { \
- if (output_format == O_I3BAR) { \
- char *_align = cfg_getstr(sec, "align"); \
- if (_align) { \
- yajl_gen_string(json_gen, (const unsigned char *) "align", strlen("align")); \
- yajl_gen_string(json_gen, (const unsigned char *)_align, strlen(_align)); \
- } \
- struct min_width *_width = cfg_getptr(sec, "min_width"); \
- if (_width) { \
- /* if the value can be parsed as a number, we use the numerical value */ \
- if (_width->num > 0) { \
- yajl_gen_string(json_gen, (const unsigned char *) "min_width", strlen("min_width")); \
- yajl_gen_integer(json_gen, _width->num); \
- } else { \
- yajl_gen_string(json_gen, (const unsigned char *) "min_width", strlen("min_width")); \
- yajl_gen_string(json_gen, (const unsigned char *)_width->str, strlen(_width->str)); \
- } \
- } \
- 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); \
- } \
+#define SEC_CLOSE_MAP \
+ do { \
+ if (output_format == O_I3BAR) { \
+ char *_align = cfg_getstr(sec, "align"); \
+ if (_align) { \
+ yajl_gen_string(json_gen, (const unsigned char *) "align", strlen("align")); \
+ yajl_gen_string(json_gen, (const unsigned char *)_align, strlen(_align)); \
+ } \
+ struct min_width *_width = cfg_getptr(sec, "min_width"); \
+ if (_width) { \
+ /* if the value can be parsed as a number, we use the numerical value */ \
+ if (_width->num > 0) { \
+ yajl_gen_string(json_gen, (const unsigned char *) "min_width", strlen("min_width")); \
+ yajl_gen_integer(json_gen, _width->num); \
+ } else { \
+ yajl_gen_string(json_gen, (const unsigned char *) "min_width", strlen("min_width")); \
+ yajl_gen_string(json_gen, (const unsigned char *)_width->str, strlen(_width->str)); \
+ } \
+ } \
+ if (cfg_size(sec, "separator") > 0) { \
+ yajl_gen_string(json_gen, (const unsigned char *) "separator", strlen("separator")); \
+ yajl_gen_bool(json_gen, cfg_getbool(sec, "separator")); \
+ } \
+ if (cfg_size(sec, "separator_block_width") > 0) { \
+ yajl_gen_string(json_gen, (const unsigned char *) "separator_block_width", strlen("separator_block_width")); \
+ yajl_gen_integer(json_gen, cfg_getint(sec, "separator_block_width")); \
+ } \
+ 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)
#define START_COLOR(colorstr) \