Allow min_width of a block in i3bar to be a string
With this change, min_width can either be an integer (as usual), or a string. In the latter case, the width of the text given by min_width determines the minimum width of the block. This way one does not have to figure out a minimum width by trial and error, only to do it again every time the font is changed.
This commit is contained in:
committed by
Michael Stapelberg
parent
7ecdcb61f8
commit
a0d5b744ab
@ -147,6 +147,10 @@ static int stdin_string(void *context, const unsigned char *val, unsigned int le
|
||||
} else {
|
||||
ctx->block.align = ALIGN_CENTER;
|
||||
}
|
||||
} else if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
|
||||
i3String *text = i3string_from_utf8_with_length((const char *)val, len);
|
||||
ctx->block.min_width = (uint32_t)predict_text_width(text);
|
||||
i3string_free(text);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user