forked from external/yambar
Add layer option
Only applies to Wayland and the default is still bottom.
This commit is contained in:
parent
7e7c011126
commit
eb94c8cceb
8 changed files with 35 additions and 1 deletions
|
@ -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).
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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},
|
||||
|
|
13
config.c
13
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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue