From 9122bad5b5f3943f6a2bc654f518cf03f6b5e5e3 Mon Sep 17 00:00:00 2001 From: domsson Date: Fri, 12 Jun 2020 05:52:02 +0900 Subject: [PATCH] Implement padding (spaces around a block's value/result) and add a second example config --- cfg/{succaderc => succaderc.1} | 1 - cfg/succaderc.2 | 40 ++++++++++++++++++++++++++++++++++ src/loadini.c | 5 +++++ src/succade.c | 7 +++--- src/succade.h | 1 + 5 files changed, 50 insertions(+), 4 deletions(-) rename cfg/{succaderc => succaderc.1} (89%) create mode 100644 cfg/succaderc.2 diff --git a/cfg/succaderc b/cfg/succaderc.1 similarity index 89% rename from cfg/succaderc rename to cfg/succaderc.1 index a713ec6..f91e5ff 100644 --- a/cfg/succaderc +++ b/cfg/succaderc.1 @@ -13,7 +13,6 @@ block-prefix = " " block-suffix = " " block-margin = 4 font = 6x13 -label-font = "-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1" [desktop] command = "bspc query -D -d focused --names" diff --git a/cfg/succaderc.2 b/cfg/succaderc.2 new file mode 100644 index 0000000..00988de --- /dev/null +++ b/cfg/succaderc.2 @@ -0,0 +1,40 @@ +[bar] +name = "testbar" +command = "lemonbar" +blocks = "desktop | user | date time" +height = 24 +foreground = "#dddddd" +label-foreground = "#333333" +block-background = "#333333" +underline = true +block-margin = 4 +block-padding = 2 +font = 6x13 +label-font = "-wuncon-siji-medium-r-normal--10-100-75-75-c-80-iso10646-1" + +[desktop] +command = "bspc query -D -d focused --names" +trigger = "bspc subscribe" +label = "  " +label-background = "#e89a6a" +margin-left = 8 + +[user] +command = "whoami" +label = "  " +label-background = "#5a8fcd" + +[date] +command = "date +'%Y-%m-%d'" +interval = 1 +label = "  " +label-background = "#7da464" + +[time] +command = "date +'%H:%M:%S'" +interval = 1 +label = "  " +label-background = "#b683c3" +mouse-left = xclock +margin-right = 8 + diff --git a/src/loadini.c b/src/loadini.c index a9d2157..f9844b3 100644 --- a/src/loadini.c +++ b/src/loadini.c @@ -91,6 +91,11 @@ int lemon_ini_handler(void *data, const char *section, const char *name, const c cfg_set_int(lc, LEMON_OPT_BLOCK_MARGIN, atoi(value)); return 1; } + if (equals(name, "block-padding") || equals(name, "padding")) + { + cfg_set_int(lc, LEMON_OPT_BLOCK_PADDING, atoi(value)); + return 1; + } if (equals(name, "block-prefix") || equals(name, "prefix")) { cfg_set_str(lc, LEMON_OPT_BLOCK_PREFIX, is_quoted(value) ? unquote(value) : strdup(value)); diff --git a/src/succade.c b/src/succade.c index 903e856..70d3db6 100644 --- a/src/succade.c +++ b/src/succade.c @@ -382,7 +382,7 @@ static char *blockstr(const thing_s *lemon, const thing_s *block) size_t diff; char *result = escape(block->output, '%', &diff); - int padding = cfg_get_int(bcfg, BLOCK_OPT_WIDTH) + diff; + int min_width = cfg_get_int(bcfg, BLOCK_OPT_WIDTH) + diff; const char *block_fg = strsel(cfg_get_str(bcfg, BLOCK_OPT_FG), "-", "-"); const char *block_bg = strsel(cfg_get_str(bcfg, BLOCK_OPT_BG), cfg_get_str(lcfg, LEMON_OPT_BLOCK_BG), "-"); @@ -391,6 +391,7 @@ static char *blockstr(const thing_s *lemon, const thing_s *block) const char *affix_fg = strsel(cfg_get_str(bcfg, BLOCK_OPT_AFFIX_FG), cfg_get_str(lcfg, LEMON_OPT_AFFIX_FG), "-"); const char *affix_bg = strsel(cfg_get_str(bcfg, BLOCK_OPT_AFFIX_BG), cfg_get_str(lcfg, LEMON_OPT_AFFIX_BG), "-"); + int padding = cfg_get_int(lcfg, LEMON_OPT_BLOCK_PADDING); int margin = cfg_get_int(lcfg, LEMON_OPT_BLOCK_MARGIN); int margin_l = cfg_has(bcfg, BLOCK_OPT_MARGIN_LEFT) ? cfg_get_int(bcfg, BLOCK_OPT_MARGIN_LEFT) : -1; int margin_r = cfg_has(bcfg, BLOCK_OPT_MARGIN_RIGHT) ? cfg_get_int(bcfg, BLOCK_OPT_MARGIN_RIGHT) : -1; @@ -416,7 +417,7 @@ static char *blockstr(const thing_s *lemon, const thing_s *block) "%s%%{F%s B%s U%s %co %cu}" "%%{T3 F%s B%s}%s" "%%{T2 F%s B%s}%s" - "%%{T1 F%s B%s}%*s" + "%%{T1 F%s B%s}%*s%*s%*s" "%%{T3 F%s B%s}%s" "%%{T- F- B- U- -o -u}%s" "%%{O%d}", @@ -429,7 +430,7 @@ static char *blockstr(const thing_s *lemon, const thing_s *block) // label label_fg, label_bg, label, // block - block_fg, block_bg, padding, result, + block_fg, block_bg, padding, "", min_width, result, padding, "", // suffix affix_fg, affix_bg, suffix, // end diff --git a/src/succade.h b/src/succade.h index 7b0c6f0..e630a09 100644 --- a/src/succade.h +++ b/src/succade.h @@ -91,6 +91,7 @@ enum succade_lemon_opt LEMON_OPT_AFFIX_FG, // block LEMON_OPT_AFFIX_BG, // block LEMON_OPT_BLOCK_MARGIN, // block + LEMON_OPT_BLOCK_PADDING, // block LEMON_OPT_BLOCK_PREFIX, // block LEMON_OPT_BLOCK_SUFFIX, // block LEMON_OPT_BLOCK_FONT,