Skip to content

Commit

Permalink
block: remove support for label
Browse files Browse the repository at this point in the history
The "label" property was specific to i3blocks and implemented as an easy
way to prefix the "full_text" property. However it brings some
inconsistencies to the user, such as the calculation of the "min_width".

For this reason, The support for the "label" key is removed.
Below are examples how to properly add a label for a "time" block.

Either you can keep the "label" key and use its value in the command:

    [time]
    label=Time:
    command=echo -n "$label"; date +%T
    interval=30

Or more cleanly with a static block on its left:

    [time-label]
    separator_block_width=0
    separator=false
    full_text=Time:

    [time]
    command=date +%T
    interval=30

Refs #219
  • Loading branch information
vivien committed Sep 10, 2018
1 parent 3877b63 commit 61646f2
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions block.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ static int block_stdout(struct block *block)

int block_update(struct block *block)
{
const char *full_text;
const char *label;
int err;

/* Reset properties to default before updating from output */
Expand All @@ -143,18 +141,6 @@ int block_update(struct block *block)
if (err)
return err;

full_text = block_get(block, "full_text") ? : "";
label = block_get(block, "label") ? : "";

if (*full_text && *label) {
const size_t sz = strlen(full_text) + strlen(label) + 2;
char concat[sz];
snprintf(concat, sz, "%s %s", label, full_text);
err = block_set(block, "full_text", concat);
if (err)
return err;
}

/* Exit code takes precedence over the output */
if (block->code == EXIT_URGENT) {
err = block_set(block, "urgent", "true");
Expand Down

0 comments on commit 61646f2

Please sign in to comment.