diff options
author | James Edwards-Jones <git@jamedjo.co.uk> | 2021-03-17 15:55:21 +0000 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-06-17 11:47:49 +0200 |
commit | d13090be546d19d487c872f7bc79bb98f8e17873 (patch) | |
tree | 60031d8768c0eedf93992c79155b89a208fdb7c8 /swaynag | |
parent | 75a4122f7a8b7313a090587d5e0074c7636c0fae (diff) |
swaynag: adds option to set wayland shell layer
Uses --layer/-y set to overlay|top|bottom|background
Diffstat (limited to 'swaynag')
-rw-r--r-- | swaynag/config.c | 23 | ||||
-rw-r--r-- | swaynag/swaynag.1.scd | 3 | ||||
-rw-r--r-- | swaynag/swaynag.5.scd | 3 | ||||
-rw-r--r-- | swaynag/swaynag.c | 3 | ||||
-rw-r--r-- | swaynag/types.c | 6 |
5 files changed, 36 insertions, 2 deletions
diff --git a/swaynag/config.c b/swaynag/config.c index c6b4e431..6db7cce5 100644 --- a/swaynag/config.c +++ b/swaynag/config.c @@ -59,6 +59,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, {"config", required_argument, NULL, 'c'}, {"debug", no_argument, NULL, 'd'}, {"edge", required_argument, NULL, 'e'}, + {"layer", required_argument, NULL, 'y'}, {"font", required_argument, NULL, 'f'}, {"help", no_argument, NULL, 'h'}, {"detailed-message", no_argument, NULL, 'l'}, @@ -104,6 +105,8 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, " -c, --config <path> Path to config file.\n" " -d, --debug Enable debugging.\n" " -e, --edge top|bottom Set the edge to use.\n" + " -y, --layer overlay|top|bottom|background\n" + " Set the layer to use.\n" " -f, --font <font> Set the font to use.\n" " -h, --help Show help message and quit.\n" " -l, --detailed-message Read a detailed message from stdin.\n" @@ -133,7 +136,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, optind = 1; while (1) { - int c = getopt_long(argc, argv, "b:B:z:Z:c:de:f:hlL:m:o:s:t:v", opts, NULL); + int c = getopt_long(argc, argv, "b:B:z:Z:c:de:y:f:hlL:m:o:s:t:v", opts, NULL); if (c == -1) { break; } @@ -184,6 +187,24 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, } } break; + case 'y': // Layer + if (type) { + if (strcmp(optarg, "background") == 0) { + type->layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND; + } else if (strcmp(optarg, "bottom") == 0) { + type->layer = ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM; + } else if (strcmp(optarg, "top") == 0) { + type->layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP; + } else if (strcmp(optarg, "overlay") == 0) { + type->layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY; + } else { + fprintf(stderr, "Invalid layer: %s\n" + "Usage: --layer overlay|top|bottom|background\n", + optarg); + return EXIT_FAILURE; + } + } + break; case 'f': // Font if (type) { free(type->font); diff --git a/swaynag/swaynag.1.scd b/swaynag/swaynag.1.scd index 4a03469e..1cc85db7 100644 --- a/swaynag/swaynag.1.scd +++ b/swaynag/swaynag.1.scd @@ -48,6 +48,9 @@ _swaynag_ [options...] *-e, --edge* top|bottom Set the edge to use. +*-y, --layer* overlay|top|bottom|background + Set the layer to use. + *-f, --font* <font> Set the font to use. diff --git a/swaynag/swaynag.5.scd b/swaynag/swaynag.5.scd index 2b583db3..3c367d0f 100644 --- a/swaynag/swaynag.5.scd +++ b/swaynag/swaynag.5.scd @@ -79,6 +79,9 @@ Additionally, the following options can be assigned a default per-type: *edge=top|bottom* Set the edge to use. +*layer=overlay|top|bottom|background* + Set the layer to use. + *font=<font>* Set the font to use. diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c index 609e4831..dd17c0b0 100644 --- a/swaynag/swaynag.c +++ b/swaynag/swaynag.c @@ -476,7 +476,8 @@ void swaynag_setup(struct swaynag *swaynag) { swaynag->layer_surface = zwlr_layer_shell_v1_get_layer_surface( swaynag->layer_shell, swaynag->surface, swaynag->output ? swaynag->output->wl_output : NULL, - ZWLR_LAYER_SHELL_V1_LAYER_TOP, "swaynag"); + swaynag->type->layer, + "swaynag"); assert(swaynag->layer_surface); zwlr_layer_surface_v1_add_listener(swaynag->layer_surface, &layer_surface_listener, swaynag); diff --git a/swaynag/types.c b/swaynag/types.c index fa045532..7bef0f87 100644 --- a/swaynag/types.c +++ b/swaynag/types.c @@ -26,6 +26,7 @@ struct swaynag_type *swaynag_type_new(const char *name) { type->button_gap_close = -1; type->button_margin_right = -1; type->button_padding = -1; + type->layer = -1; return type; } @@ -35,6 +36,7 @@ void swaynag_types_add_default(list_t *types) { type_defaults->anchors = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; + type_defaults->layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP; type_defaults->button_background = 0x333333FF; type_defaults->details_background = 0x333333FF; type_defaults->background = 0x323232FF; @@ -100,6 +102,10 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) { dest->anchors = src->anchors; } + if (src->layer >= 0) { + dest->layer = src->layer; + } + // Colors if (src->button_background > 0) { dest->button_background = src->button_background; |