Skip to content

Commit

Permalink
Implement padding (spaces around a block's value/result) and add a se…
Browse files Browse the repository at this point in the history
…cond example config
  • Loading branch information
domsson committed Jun 11, 2020
1 parent 238fbac commit 9122bad
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
1 change: 0 additions & 1 deletion cfg/succaderc → cfg/succaderc.1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
40 changes: 40 additions & 0 deletions cfg/succaderc.2
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions src/loadini.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 4 additions & 3 deletions src/succade.c
Original file line number Diff line number Diff line change
Expand Up @@ -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), "-");
Expand All @@ -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;
Expand All @@ -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}",
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/succade.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9122bad

Please sign in to comment.