diff --git a/CHANGELOG.md b/CHANGELOG.md index 160575c..48a0e9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ individually. `border.width` is now a short-hand for setting all four borders to the same value (https://codeberg.org/dnkl/yambar/issues/77). +* bar: `layer: top|bottom`, allowing the layer which the bar is + rendered on to be changed. Wayland only - ignored on X11. * river: `per-output: false|true`. * `-d,--log-level=info|warning|error|none` command line option (https://codeberg.org/dnkl/yambar/issues/84). diff --git a/bar/bar.c b/bar/bar.c index 9d07830..21d95c5 100644 --- a/bar/bar.c +++ b/bar/bar.c @@ -433,6 +433,7 @@ bar_new(const struct bar_config *config) struct private *priv = calloc(1, sizeof(*priv)); priv->monitor = config->monitor != NULL ? strdup(config->monitor) : NULL; + priv->layer = config->layer; priv->location = config->location; priv->height = config->height; priv->background = config->background; diff --git a/bar/bar.h b/bar/bar.h index 45fb328..c9f94f4 100644 --- a/bar/bar.h +++ b/bar/bar.h @@ -17,12 +17,14 @@ struct bar { }; enum bar_location { BAR_TOP, BAR_BOTTOM }; +enum bar_layer { BAR_LAYER_TOP, BAR_LAYER_BOTTOM }; enum bar_backend { BAR_BACKEND_AUTO, BAR_BACKEND_XCB, BAR_BACKEND_WAYLAND }; struct bar_config { enum bar_backend backend; const char *monitor; + enum bar_layer layer; enum bar_location location; int height; int left_spacing, right_spacing; diff --git a/bar/private.h b/bar/private.h index 56e59bb..f216c99 100644 --- a/bar/private.h +++ b/bar/private.h @@ -6,6 +6,7 @@ struct private { /* From bar_config */ char *monitor; + enum bar_layer layer; enum bar_location location; int height; int left_spacing, right_spacing; diff --git a/bar/wayland.c b/bar/wayland.c index cb10eae..270b4ff 100644 --- a/bar/wayland.c +++ b/bar/wayland.c @@ -988,10 +988,14 @@ setup(struct bar *_bar) wl_surface_add_listener(backend->surface, &surface_listener, backend); + enum zwlr_layer_shell_v1_layer layer = bar->layer == BAR_LAYER_BOTTOM + ? ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM + : ZWLR_LAYER_SHELL_V1_LAYER_TOP; + backend->layer_surface = zwlr_layer_shell_v1_get_layer_surface( backend->layer_shell, backend->surface, backend->monitor != NULL ? backend->monitor->output : NULL, - ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "panel"); + layer, "panel"); if (backend->layer_surface == NULL) { LOG_ERR("failed to create layer shell surface"); diff --git a/config-verify.c b/config-verify.c index 5d4089a..67b21e1 100644 --- a/config-verify.c +++ b/config-verify.c @@ -404,6 +404,12 @@ verify_bar_location(keychain_t *chain, const struct yml_node *node) return conf_verify_enum(chain, node, (const char *[]){"top", "bottom"}, 2); } +static bool +verify_bar_layer(keychain_t *chain, const struct yml_node *node) +{ + return conf_verify_enum(chain, node, (const char *[]){"top", "bottom"}, 2); +} + bool conf_verify_bar(const struct yml_node *bar) { @@ -421,6 +427,7 @@ conf_verify_bar(const struct yml_node *bar) {"background", true, &conf_verify_color}, {"monitor", false, &conf_verify_string}, + {"layer", false, &verify_bar_layer}, {"spacing", false, &conf_verify_int}, {"left-spacing", false, &conf_verify_int}, diff --git a/config.c b/config.c index 241e25b..7f9583e 100644 --- a/config.c +++ b/config.c @@ -204,6 +204,7 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend) struct bar_config conf = { .backend = backend, + .layer = BAR_LAYER_BOTTOM, }; /* @@ -228,6 +229,18 @@ conf_to_bar(const struct yml_node *bar, enum bar_backend backend) if (monitor != NULL) conf.monitor = yml_value_as_string(monitor); + const struct yml_node *layer = yml_get_value(bar, "layer"); + if (layer != NULL) { + const char *tmp = yml_value_as_string(layer); + if (strcmp(tmp, "top") == 0) + conf.layer = BAR_LAYER_TOP; + else if (strcmp(tmp, "bottom") == 0) + conf.layer = BAR_LAYER_BOTTOM; + else + assert(false); + } + + const struct yml_node *spacing = yml_get_value(bar, "spacing"); if (spacing != NULL) conf.left_spacing = conf.right_spacing = yml_value_as_int(spacing); diff --git a/doc/yambar.5.scd b/doc/yambar.5.scd index 9e1eefa..47041fb 100644 --- a/doc/yambar.5.scd +++ b/doc/yambar.5.scd @@ -45,6 +45,10 @@ types that are frequently used: : no : Monitor to place the bar on. If not specified, the primary monitor will be used +| layer +: string +: no +: Layer to put bar on. One of _top_ or _bottom_. Wayland only | left-spacing : int : no