From 1bd8463481c5272094a084a76ab558a45e18bd15 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 28 Nov 2018 11:23:48 -0500 Subject: Implement bar gaps Adds the bar subcommand `gaps | | ` to set gaps for swaybar. Due to restrictions on margins for a layer_surface, only the sides that are anchored to an edge of the screen can have gaps. Since there is support for per-side outer gaps for workspaces, those should be able to be used instead for the last side. --- swaybar/ipc.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'swaybar/ipc.c') diff --git a/swaybar/ipc.c b/swaybar/ipc.c index db4360c1..2b930786 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -153,7 +153,7 @@ static bool ipc_parse_config( return false; } json_object *markup, *mode, *hidden_state, *position, *status_command; - json_object *font, *bar_height, *wrap_scroll, *workspace_buttons; + json_object *font, *gaps, *bar_height, *wrap_scroll, *workspace_buttons; json_object *strip_workspace_numbers, *strip_workspace_name; json_object *binding_mode_indicator, *verbose, *colors, *sep_symbol; json_object *outputs, *bindings; @@ -162,6 +162,7 @@ static bool ipc_parse_config( json_object_object_get_ex(bar_config, "position", &position); json_object_object_get_ex(bar_config, "status_command", &status_command); json_object_object_get_ex(bar_config, "font", &font); + json_object_object_get_ex(bar_config, "gaps", &gaps); json_object_object_get_ex(bar_config, "bar_height", &bar_height); json_object_object_get_ex(bar_config, "wrap_scroll", &wrap_scroll); json_object_object_get_ex(bar_config, "workspace_buttons", &workspace_buttons); @@ -207,6 +208,24 @@ static bool ipc_parse_config( if (bar_height) { config->height = json_object_get_int(bar_height); } + if (gaps) { + json_object *top = json_object_object_get(gaps, "top"); + if (top) { + config->gaps.top = json_object_get_int(top); + } + json_object *right = json_object_object_get(gaps, "right"); + if (right) { + config->gaps.right = json_object_get_int(right); + } + json_object *bottom = json_object_object_get(gaps, "bottom"); + if (bottom) { + config->gaps.bottom = json_object_get_int(bottom); + } + json_object *left = json_object_object_get(gaps, "left"); + if (left) { + config->gaps.left = json_object_get_int(left); + } + } if (markup) { config->pango_markup = json_object_get_boolean(markup); } @@ -446,6 +465,27 @@ static bool handle_barconfig_update(struct swaybar *bar, config->mode = strdup(json_object_get_string(json_mode)); wlr_log(WLR_DEBUG, "Changing bar mode to %s", config->mode); + json_object *gaps; + json_object_object_get_ex(json_config, "gaps", &gaps); + if (gaps) { + json_object *top = json_object_object_get(gaps, "top"); + if (top) { + config->gaps.top = json_object_get_int(top); + } + json_object *right = json_object_object_get(gaps, "right"); + if (right) { + config->gaps.right = json_object_get_int(right); + } + json_object *bottom = json_object_object_get(gaps, "bottom"); + if (bottom) { + config->gaps.bottom = json_object_get_int(bottom); + } + json_object *left = json_object_object_get(gaps, "left"); + if (left) { + config->gaps.left = json_object_get_int(left); + } + } + return determine_bar_visibility(bar, true); } -- cgit v1.2.3-70-g09d2