From eb1c09030ece6fcf0c6b387c8b74ded106eccecb Mon Sep 17 00:00:00 2001 From: Mustafa Abdul-Kader Date: Tue, 8 Sep 2020 21:43:35 -0500 Subject: swaynag: add details background option Adds a new config option for details background for swaynag issue/#5673 --- swaynag/config.c | 8 ++++++++ swaynag/render.c | 4 ++-- swaynag/swaynag.1.scd | 3 +++ swaynag/swaynag.5.scd | 3 +++ swaynag/types.c | 7 +++++++ 5 files changed, 23 insertions(+), 2 deletions(-) (limited to 'swaynag') diff --git a/swaynag/config.c b/swaynag/config.c index 3488a74d..a57597ef 100644 --- a/swaynag/config.c +++ b/swaynag/config.c @@ -38,6 +38,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, TO_COLOR_BORDER, TO_COLOR_BORDER_BOTTOM, TO_COLOR_BUTTON, + TO_COLOR_DETAILS, TO_COLOR_TEXT, TO_COLOR_BUTTON_TEXT, TO_THICK_BAR_BORDER, @@ -77,6 +78,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, {"border-bottom-size", required_argument, NULL, TO_THICK_BAR_BORDER}, {"message-padding", required_argument, NULL, TO_PADDING_MESSAGE}, {"details-border-size", required_argument, NULL, TO_THICK_DET_BORDER}, + {"details-background", required_argument, NULL, TO_COLOR_DETAILS}, {"button-border-size", required_argument, NULL, TO_THICK_BTN_BORDER}, {"button-gap", required_argument, NULL, TO_GAP_BTN}, {"button-dismiss-gap", required_argument, NULL, TO_GAP_BTN_DISMISS}, @@ -122,6 +124,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, " --border-bottom-size size Thickness of the bar border.\n" " --message-padding padding Padding for the message.\n" " --details-border-size size Thickness for the details border.\n" + " --details-background RRGGBB[AA] Details background color.\n" " --button-border-size size Thickness for the button border.\n" " --button-gap gap Size of the gap between buttons\n" " --button-dismiss-gap gap Size of the gap for dismiss button.\n" @@ -253,6 +256,11 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag, fprintf(stderr, "Invalid button background color: %s", optarg); } break; + case TO_COLOR_DETAILS: // Details background color + if (type && !parse_color(optarg, &type->details_background)) { + fprintf(stderr, "Invalid details background color: %s", optarg); + } + break; case TO_COLOR_TEXT: // Text color if (type && !parse_color(optarg, &type->text)) { fprintf(stderr, "Invalid text color: %s", optarg); diff --git a/swaynag/render.c b/swaynag/render.c index 4537ec04..cf2cc9e0 100644 --- a/swaynag/render.c +++ b/swaynag/render.c @@ -37,7 +37,7 @@ static void render_details_scroll_button(cairo_t *cairo, int border = swaynag->type->button_border_thickness * swaynag->scale; int padding = swaynag->type->button_padding * swaynag->scale; - cairo_set_source_u32(cairo, swaynag->type->border); + cairo_set_source_u32(cairo, swaynag->type->details_background); cairo_rectangle(cairo, button->x, button->y, button->width, button->height); cairo_fill(cairo); @@ -153,7 +153,7 @@ static uint32_t render_detailed(cairo_t *cairo, struct swaynag *swaynag, &swaynag->details.button_down); } - cairo_set_source_u32(cairo, swaynag->type->border); + cairo_set_source_u32(cairo, swaynag->type->details_background); cairo_rectangle(cairo, swaynag->details.x, swaynag->details.y, swaynag->details.width, swaynag->details.height); cairo_fill(cairo); diff --git a/swaynag/swaynag.1.scd b/swaynag/swaynag.1.scd index 61a69909..4a03469e 100644 --- a/swaynag/swaynag.1.scd +++ b/swaynag/swaynag.1.scd @@ -106,6 +106,9 @@ _swaynag_ [options...] *--message-padding* Set the padding for the message. +*--details-background* + Set the color for the background for details. + *--details-border-size* Set the thickness for the details border. diff --git a/swaynag/swaynag.5.scd b/swaynag/swaynag.5.scd index 87f21423..a078a4d7 100644 --- a/swaynag/swaynag.5.scd +++ b/swaynag/swaynag.5.scd @@ -53,6 +53,9 @@ The following sizing options can also be set: *message-padding=* Set the padding for the message. +*details-gackground=* + The background color for the details. + *details-border-size=* Set the thickness for the details border. diff --git a/swaynag/types.c b/swaynag/types.c index 576dcbff..fa045532 100644 --- a/swaynag/types.c +++ b/swaynag/types.c @@ -36,6 +36,7 @@ void swaynag_types_add_default(list_t *types) { | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; type_defaults->button_background = 0x333333FF; + type_defaults->details_background = 0x333333FF; type_defaults->background = 0x323232FF; type_defaults->text = 0xFFFFFFFF; type_defaults->button_text = 0xFFFFFFFF; @@ -53,6 +54,7 @@ void swaynag_types_add_default(list_t *types) { struct swaynag_type *type_error = swaynag_type_new("error"); type_error->button_background = 0x680A0AFF; + type_error->details_background = 0x680A0AFF; type_error->background = 0x900000FF; type_error->text = 0xFFFFFFFF; type_error->button_text = 0xFFFFFFFF; @@ -62,6 +64,7 @@ void swaynag_types_add_default(list_t *types) { struct swaynag_type *type_warning = swaynag_type_new("warning"); type_warning->button_background = 0xFFC100FF; + type_warning->details_background = 0xFFC100FF; type_warning->background = 0xFFA800FF; type_warning->text = 0x000000FF; type_warning->button_text = 0x000000FF; @@ -102,6 +105,10 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) { dest->button_background = src->button_background; } + if (src->details_background > 0) { + dest->details_background = src->details_background; + } + if (src->background > 0) { dest->background = src->background; } -- cgit v1.2.3