Separator color via config; separator width and on/off via ipc
This patch adds the following features: 1) Configure a color of the separator via config. It is done like bar { colors { separator #000000 } } 2) A block can have an integer entry "separator_block_width" which sets the width of the gap which would follow after the current block. 3) A block can have a boolean entry "separator" and if it is set to false, then the drawing of the separating line would be disabled.
This commit is contained in:
parent
a52b1b4bb0
commit
5f05ca6b5d
|
@ -154,6 +154,14 @@ urgent::
|
|||
A boolean which specifies whether the current value is urgent. Examples
|
||||
are battery charge values below 1 percent or no more available disk
|
||||
space (for non-root users). The presentation of urgency is up to i3bar.
|
||||
separator::
|
||||
The boolean value false disables drawing of a separating line after the
|
||||
block. If the field is not present then the separator will be still
|
||||
drawn. Keep in mind that absence of a separator is only responsible for
|
||||
the line itself, the gap between the items would be still present.
|
||||
separator_block_width::
|
||||
The integer value that sets the width of the gap between items in pixels.
|
||||
In the middle of the gap, a separating line is going to be drawn.
|
||||
|
||||
If you want to put in your own entries into a block, prefix the key with an
|
||||
underscore (_). i3bar will ignore all keys it doesn’t understand, and prefixing
|
||||
|
|
2
docs/ipc
2
docs/ipc
|
@ -507,6 +507,8 @@ background::
|
|||
Background color of the bar.
|
||||
statusline::
|
||||
Text color to be used for the statusline.
|
||||
separator::
|
||||
Text color to be used for the separator.
|
||||
focused_workspace_text/focused_workspace_bg::
|
||||
Text color/background color for a workspace button when the workspace
|
||||
has focus.
|
||||
|
|
|
@ -1155,6 +1155,8 @@ background::
|
|||
Background color of the bar.
|
||||
statusline::
|
||||
Text color to be used for the statusline.
|
||||
separator::
|
||||
Text color to be used for the separator.
|
||||
focused_workspace::
|
||||
Border, background and text color for a workspace button when the workspace
|
||||
has focus.
|
||||
|
@ -1176,6 +1178,7 @@ urgent_workspace::
|
|||
colors {
|
||||
background <color>
|
||||
statusline <color>
|
||||
separator <color>
|
||||
|
||||
colorclass <border> <background> <text>
|
||||
}
|
||||
|
@ -1187,6 +1190,7 @@ bar {
|
|||
colors {
|
||||
background #000000
|
||||
statusline #ffffff
|
||||
separator #666666
|
||||
|
||||
focused_workspace #4c7899 #285577 #ffffff
|
||||
active_workspace #333333 #5f676a #ffffff
|
||||
|
|
|
@ -43,6 +43,10 @@ struct status_block {
|
|||
blockalign_t align;
|
||||
|
||||
bool urgent;
|
||||
bool no_separator;
|
||||
|
||||
/* The amount of pixels necessary to render a separater after the block. */
|
||||
uint32_t sep_block_width;
|
||||
|
||||
/* The amount of pixels necessary to render this block. These variables are
|
||||
* only temporarily used in refresh_statusline(). */
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
struct xcb_color_strings_t {
|
||||
char *bar_fg;
|
||||
char *bar_bg;
|
||||
char *sep_fg;
|
||||
char *active_ws_fg;
|
||||
char *active_ws_bg;
|
||||
char *active_ws_border;
|
||||
|
|
|
@ -98,6 +98,10 @@ static int stdin_start_array(void *context) {
|
|||
static int stdin_start_map(void *context) {
|
||||
parser_ctx *ctx = context;
|
||||
memset(&(ctx->block), '\0', sizeof(struct status_block));
|
||||
|
||||
/* Default width of the separator block. */
|
||||
ctx->block.sep_block_width = 9;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -117,6 +121,9 @@ static int stdin_boolean(void *context, int val) {
|
|||
if (strcasecmp(ctx->last_map_key, "urgent") == 0) {
|
||||
ctx->block.urgent = val;
|
||||
}
|
||||
if (strcasecmp(ctx->last_map_key, "separator") == 0) {
|
||||
ctx->block.no_separator = !val;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -153,6 +160,9 @@ static int stdin_integer(void *context, long val) {
|
|||
if (strcasecmp(ctx->last_map_key, "min_width") == 0) {
|
||||
ctx->block.min_width = (uint32_t)val;
|
||||
}
|
||||
if (strcasecmp(ctx->last_map_key, "separator_block_width") == 0) {
|
||||
ctx->block.sep_block_width = (uint32_t)val;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ static int config_string_cb(void *params_, const unsigned char *val, unsigned in
|
|||
|
||||
COLOR(statusline, bar_fg);
|
||||
COLOR(background, bar_bg);
|
||||
COLOR(separator, sep_fg);
|
||||
COLOR(focused_workspace_border, focus_ws_border);
|
||||
COLOR(focused_workspace_bg, focus_ws_bg);
|
||||
COLOR(focused_workspace_text, focus_ws_fg);
|
||||
|
@ -260,6 +261,7 @@ void free_colors(struct xcb_color_strings_t *colors) {
|
|||
} while (0)
|
||||
FREE_COLOR(bar_fg);
|
||||
FREE_COLOR(bar_bg);
|
||||
FREE_COLOR(sep_fg);
|
||||
FREE_COLOR(active_ws_fg);
|
||||
FREE_COLOR(active_ws_bg);
|
||||
FREE_COLOR(active_ws_border);
|
||||
|
|
|
@ -84,6 +84,7 @@ static mode binding;
|
|||
struct xcb_colors_t {
|
||||
uint32_t bar_fg;
|
||||
uint32_t bar_bg;
|
||||
uint32_t sep_fg;
|
||||
uint32_t active_ws_fg;
|
||||
uint32_t active_ws_bg;
|
||||
uint32_t active_ws_border;
|
||||
|
@ -149,7 +150,8 @@ void refresh_statusline(void) {
|
|||
|
||||
/* If this is not the last block, add some pixels for a separator. */
|
||||
if (TAILQ_NEXT(block, blocks) != NULL)
|
||||
block->width += 9;
|
||||
block->width += block->sep_block_width;
|
||||
|
||||
statusline_width += block->width + block->x_offset + block->x_append;
|
||||
}
|
||||
|
||||
|
@ -174,12 +176,14 @@ void refresh_statusline(void) {
|
|||
draw_text(block->full_text, statusline_pm, statusline_ctx, x + block->x_offset, 1, block->width);
|
||||
x += block->width + block->x_offset + block->x_append;
|
||||
|
||||
if (TAILQ_NEXT(block, blocks) != NULL) {
|
||||
if (TAILQ_NEXT(block, blocks) != NULL && !block->no_separator && block->sep_block_width > 0) {
|
||||
/* This is not the last block, draw a separator. */
|
||||
set_font_colors(statusline_ctx, get_colorpixel("#666666"), colors.bar_bg);
|
||||
uint32_t sep_offset = block->sep_block_width/2 + block->sep_block_width % 2;
|
||||
set_font_colors(statusline_ctx, colors.sep_fg, colors.bar_bg);
|
||||
xcb_poly_line(xcb_connection, XCB_COORD_MODE_ORIGIN, statusline_pm,
|
||||
statusline_ctx, 2,
|
||||
(xcb_point_t[]){ { x - 5, 2 }, { x - 5, font.height - 2 } });
|
||||
(xcb_point_t[]){ { x - sep_offset, 2 },
|
||||
{ x - sep_offset, font.height - 2 } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,6 +263,7 @@ void init_colors(const struct xcb_color_strings_t *new_colors) {
|
|||
} while (0)
|
||||
PARSE_COLOR(bar_fg, "#FFFFFF");
|
||||
PARSE_COLOR(bar_bg, "#000000");
|
||||
PARSE_COLOR(sep_fg, "#666666");
|
||||
PARSE_COLOR(active_ws_fg, "#FFFFFF");
|
||||
PARSE_COLOR(active_ws_bg, "#333333");
|
||||
PARSE_COLOR(active_ws_border, "#333333");
|
||||
|
|
|
@ -267,6 +267,7 @@ struct Barconfig {
|
|||
struct bar_colors {
|
||||
char *background;
|
||||
char *statusline;
|
||||
char *separator;
|
||||
|
||||
char *focused_workspace_border;
|
||||
char *focused_workspace_bg;
|
||||
|
|
|
@ -419,7 +419,7 @@ state BAR_COLORS:
|
|||
end ->
|
||||
'#' -> BAR_COLORS_IGNORE_LINE
|
||||
'set' -> BAR_COLORS_IGNORE_LINE
|
||||
colorclass = 'background', 'statusline'
|
||||
colorclass = 'background', 'statusline', 'separator'
|
||||
-> BAR_COLORS_SINGLE
|
||||
colorclass = 'focused_workspace', 'active_workspace', 'inactive_workspace', 'urgent_workspace'
|
||||
-> BAR_COLORS_BORDER
|
||||
|
|
|
@ -526,7 +526,10 @@ CFGFUN(bar_tray_output, const char *output) {
|
|||
CFGFUN(bar_color_single, const char *colorclass, const char *color) {
|
||||
if (strcmp(colorclass, "background") == 0)
|
||||
current_bar.colors.background = sstrdup(color);
|
||||
else current_bar.colors.statusline = sstrdup(color);
|
||||
else if (strcmp(colorclass, "separator") == 0)
|
||||
current_bar.colors.separator = sstrdup(color);
|
||||
else
|
||||
current_bar.colors.statusline = sstrdup(color);
|
||||
}
|
||||
|
||||
CFGFUN(bar_status_command, const char *command) {
|
||||
|
|
Loading…
Reference in New Issue