aboutsummaryrefslogtreecommitdiff
path: root/swaynag
diff options
context:
space:
mode:
authoroliver-giersch <oliver.giersch@gmail.com>2020-09-02 15:03:48 +0200
committerSimon Ser <contact@emersion.fr>2020-09-04 18:17:42 +0200
commita543fa35ffc93b832770988121209d4e939a2237 (patch)
tree24e1123ea087439d4dfdba3770bdcfc8bf16800e /swaynag
parent08095e99f3cc1697bc3f20d166a2c19374537afd (diff)
swaynag: adds option to separately specify the text color for buttons
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/config.c58
-rw-r--r--swaynag/render.c4
-rw-r--r--swaynag/swaynag.1.scd3
-rw-r--r--swaynag/swaynag.5.scd3
-rw-r--r--swaynag/types.c8
5 files changed, 49 insertions, 27 deletions
diff --git a/swaynag/config.c b/swaynag/config.c
index d702cc95..3488a74d 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -39,6 +39,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
TO_COLOR_BORDER_BOTTOM,
TO_COLOR_BUTTON,
TO_COLOR_TEXT,
+ TO_COLOR_BUTTON_TEXT,
TO_THICK_BAR_BORDER,
TO_PADDING_MESSAGE,
TO_THICK_DET_BORDER,
@@ -72,6 +73,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
{"border-bottom", required_argument, NULL, TO_COLOR_BORDER_BOTTOM},
{"button-background", required_argument, NULL, TO_COLOR_BUTTON},
{"text", required_argument, NULL, TO_COLOR_TEXT},
+ {"button-text", required_argument, NULL, TO_COLOR_BUTTON_TEXT},
{"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},
@@ -97,33 +99,34 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
"Multiple buttons can be defined.\n"
" -Z, --button-dismiss-no-terminal <text> <action> Like "
"--button-dismiss, but does not run the action in a terminal.\n"
- " -c, --config <path> Path to config file.\n"
- " -d, --debug Enable debugging.\n"
- " -e, --edge top|bottom Set the edge 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"
- " -L, --detailed-button <text> Set the text of the detail button.\n"
- " -m, --message <msg> Set the message text.\n"
- " -o, --output <output> Set the output to use.\n"
- " -s, --dismiss-button <text> Set the dismiss button text.\n"
- " -t, --type <type> Set the message type.\n"
- " -v, --version Show the version number and quit.\n"
+ " -c, --config <path> Path to config file.\n"
+ " -d, --debug Enable debugging.\n"
+ " -e, --edge top|bottom Set the edge 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"
+ " -L, --detailed-button <text> Set the text of the detail button.\n"
+ " -m, --message <msg> Set the message text.\n"
+ " -o, --output <output> Set the output to use.\n"
+ " -s, --dismiss-button <text> Set the dismiss button text.\n"
+ " -t, --type <type> Set the message type.\n"
+ " -v, --version Show the version number and quit.\n"
"\n"
"The following appearance options can also be given:\n"
- " --background RRGGBB[AA] Background color.\n"
- " --border RRGGBB[AA] Border color.\n"
- " --border-bottom RRGGBB[AA] Bottom border color.\n"
- " --button-background RRGGBB[AA] Button background color.\n"
- " --text RRGGBB[AA] Text color.\n"
- " --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"
- " --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"
- " --button-margin-right margin Margin from dismiss button to edge.\n"
- " --button-padding padding Padding for the button text.\n";
+ " --background RRGGBB[AA] Background color.\n"
+ " --border RRGGBB[AA] Border color.\n"
+ " --border-bottom RRGGBB[AA] Bottom border color.\n"
+ " --button-background RRGGBB[AA] Button background color.\n"
+ " --text RRGGBB[AA] Text color.\n"
+ " --button-text RRGGBB[AA] Button text color.\n"
+ " --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"
+ " --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"
+ " --button-margin-right margin Margin from dismiss button to edge.\n"
+ " --button-padding padding Padding for the button text.\n";
optind = 1;
while (1) {
@@ -255,6 +258,11 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
fprintf(stderr, "Invalid text color: %s", optarg);
}
break;
+ case TO_COLOR_BUTTON_TEXT: // Button text color
+ if (type && !parse_color(optarg, &type->button_text)) {
+ fprintf(stderr, "Invalid button text color: %s", optarg);
+ }
+ break;
case TO_THICK_BAR_BORDER: // Bottom border thickness
if (type) {
type->bar_border_thickness = strtol(optarg, NULL, 0);
diff --git a/swaynag/render.c b/swaynag/render.c
index f6507e67..4537ec04 100644
--- a/swaynag/render.c
+++ b/swaynag/render.c
@@ -47,7 +47,7 @@ static void render_details_scroll_button(cairo_t *cairo,
button->width - (border * 2), button->height - (border * 2));
cairo_fill(cairo);
- cairo_set_source_u32(cairo, swaynag->type->text);
+ cairo_set_source_u32(cairo, swaynag->type->button_text);
cairo_move_to(cairo, button->x + border + padding,
button->y + border + (button->height - text_height) / 2);
pango_printf(cairo, swaynag->type->font, swaynag->scale, true,
@@ -199,7 +199,7 @@ static uint32_t render_button(cairo_t *cairo, struct swaynag *swaynag,
button->width, button->height);
cairo_fill(cairo);
- cairo_set_source_u32(cairo, swaynag->type->text);
+ cairo_set_source_u32(cairo, swaynag->type->button_text);
cairo_move_to(cairo, button->x + padding, button->y + padding);
pango_printf(cairo, swaynag->type->font, swaynag->scale, true,
"%s", button->text);
diff --git a/swaynag/swaynag.1.scd b/swaynag/swaynag.1.scd
index 2ce7f330..61a69909 100644
--- a/swaynag/swaynag.1.scd
+++ b/swaynag/swaynag.1.scd
@@ -97,6 +97,9 @@ _swaynag_ [options...]
*--text* <RRGGBB[AA]>
Set the text color.
+*--button-text* <RRGGBB[AA]>
+ Set the button text color.
+
*--border-bottom-size* <size>
Set the thickness of the bottom border.
diff --git a/swaynag/swaynag.5.scd b/swaynag/swaynag.5.scd
index d3daadf7..87f21423 100644
--- a/swaynag/swaynag.5.scd
+++ b/swaynag/swaynag.5.scd
@@ -42,6 +42,9 @@ colors can be set:
*text=<color>*
The color of the text.
+*button-text=<color>*
+ The color of the button text.
+
The following sizing options can also be set:
*border-bottom-size=<size>*
diff --git a/swaynag/types.c b/swaynag/types.c
index 4caaf6f7..576dcbff 100644
--- a/swaynag/types.c
+++ b/swaynag/types.c
@@ -38,6 +38,7 @@ void swaynag_types_add_default(list_t *types) {
type_defaults->button_background = 0x333333FF;
type_defaults->background = 0x323232FF;
type_defaults->text = 0xFFFFFFFF;
+ type_defaults->button_text = 0xFFFFFFFF;
type_defaults->border = 0x222222FF;
type_defaults->border_bottom = 0x444444FF;
type_defaults->bar_border_thickness = 2;
@@ -54,6 +55,7 @@ void swaynag_types_add_default(list_t *types) {
type_error->button_background = 0x680A0AFF;
type_error->background = 0x900000FF;
type_error->text = 0xFFFFFFFF;
+ type_error->button_text = 0xFFFFFFFF;
type_error->border = 0xD92424FF;
type_error->border_bottom = 0x470909FF;
list_add(types, type_error);
@@ -62,6 +64,7 @@ void swaynag_types_add_default(list_t *types) {
type_warning->button_background = 0xFFC100FF;
type_warning->background = 0xFFA800FF;
type_warning->text = 0x000000FF;
+ type_warning->button_text = 0x000000FF;
type_warning->border = 0xAB7100FF;
type_warning->border_bottom = 0xAB7100FF;
list_add(types, type_warning);
@@ -107,6 +110,11 @@ void swaynag_type_merge(struct swaynag_type *dest, struct swaynag_type *src) {
dest->text = src->text;
}
+ if (src->button_text > 0) {
+ dest->button_text = src->button_text;
+ }
+
+
if (src->border > 0) {
dest->border = src->border;
}