Merge remote-tracking branch 'upstream/master' into master

This commit is contained in:
TheAvidDev 2020-09-04 15:14:49 -04:00
commit 7021e9f43b
7 changed files with 53 additions and 28 deletions

View file

@ -9,6 +9,7 @@ struct swaynag_type {
uint32_t anchors; uint32_t anchors;
// Colors // Colors
uint32_t button_text;
uint32_t button_background; uint32_t button_background;
uint32_t background; uint32_t background;
uint32_t text; uint32_t text;

View file

@ -51,7 +51,9 @@ _swaymsg_ [options...] [message]
If you have quoted multi-word strings in your command, enclose the entire If you have quoted multi-word strings in your command, enclose the entire
command in single-quotes. For example, use command in single-quotes. For example, use
_swaymsg 'output "Foobar Display" enable'_ instead of _swaymsg 'output "Foobar Display" enable'_ instead of
_swaymsg output "Foobar Display" enable_. _swaymsg output "Foobar Display" enable_. Furthermore, note that comma
separated options also count as multi-word strings, because commas can be
used to execute commands on the same line.
- If you are providing a command that contains a leading hyphen (_-_), insert - If you are providing a command that contains a leading hyphen (_-_), insert
two hyphens (_--_) before the command to signal to swaymsg not to parse two hyphens (_--_) before the command to signal to swaymsg not to parse
anything beyond that point as an option. For example, use anything beyond that point as an option. For example, use

View file

@ -39,6 +39,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
TO_COLOR_BORDER_BOTTOM, TO_COLOR_BORDER_BOTTOM,
TO_COLOR_BUTTON, TO_COLOR_BUTTON,
TO_COLOR_TEXT, TO_COLOR_TEXT,
TO_COLOR_BUTTON_TEXT,
TO_THICK_BAR_BORDER, TO_THICK_BAR_BORDER,
TO_PADDING_MESSAGE, TO_PADDING_MESSAGE,
TO_THICK_DET_BORDER, 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}, {"border-bottom", required_argument, NULL, TO_COLOR_BORDER_BOTTOM},
{"button-background", required_argument, NULL, TO_COLOR_BUTTON}, {"button-background", required_argument, NULL, TO_COLOR_BUTTON},
{"text", required_argument, NULL, TO_COLOR_TEXT}, {"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}, {"border-bottom-size", required_argument, NULL, TO_THICK_BAR_BORDER},
{"message-padding", required_argument, NULL, TO_PADDING_MESSAGE}, {"message-padding", required_argument, NULL, TO_PADDING_MESSAGE},
{"details-border-size", required_argument, NULL, TO_THICK_DET_BORDER}, {"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" "Multiple buttons can be defined.\n"
" -Z, --button-dismiss-no-terminal <text> <action> Like " " -Z, --button-dismiss-no-terminal <text> <action> Like "
"--button-dismiss, but does not run the action in a terminal.\n" "--button-dismiss, but does not run the action in a terminal.\n"
" -c, --config <path> Path to config file.\n" " -c, --config <path> Path to config file.\n"
" -d, --debug Enable debugging.\n" " -d, --debug Enable debugging.\n"
" -e, --edge top|bottom Set the edge to use.\n" " -e, --edge top|bottom Set the edge to use.\n"
" -f, --font <font> Set the font to use.\n" " -f, --font <font> Set the font to use.\n"
" -h, --help Show help message and quit.\n" " -h, --help Show help message and quit.\n"
" -l, --detailed-message Read a detailed message from stdin.\n" " -l, --detailed-message Read a detailed message from stdin.\n"
" -L, --detailed-button <text> Set the text of the detail button.\n" " -L, --detailed-button <text> Set the text of the detail button.\n"
" -m, --message <msg> Set the message text.\n" " -m, --message <msg> Set the message text.\n"
" -o, --output <output> Set the output to use.\n" " -o, --output <output> Set the output to use.\n"
" -s, --dismiss-button <text> Set the dismiss button text.\n" " -s, --dismiss-button <text> Set the dismiss button text.\n"
" -t, --type <type> Set the message type.\n" " -t, --type <type> Set the message type.\n"
" -v, --version Show the version number and quit.\n" " -v, --version Show the version number and quit.\n"
"\n" "\n"
"The following appearance options can also be given:\n" "The following appearance options can also be given:\n"
" --background RRGGBB[AA] Background color.\n" " --background RRGGBB[AA] Background color.\n"
" --border RRGGBB[AA] Border color.\n" " --border RRGGBB[AA] Border color.\n"
" --border-bottom RRGGBB[AA] Bottom border color.\n" " --border-bottom RRGGBB[AA] Bottom border color.\n"
" --button-background RRGGBB[AA] Button background color.\n" " --button-background RRGGBB[AA] Button background color.\n"
" --text RRGGBB[AA] Text color.\n" " --text RRGGBB[AA] Text color.\n"
" --border-bottom-size size Thickness of the bar border.\n" " --button-text RRGGBB[AA] Button text color.\n"
" --message-padding padding Padding for the message.\n" " --border-bottom-size size Thickness of the bar border.\n"
" --details-border-size size Thickness for the details border.\n" " --message-padding padding Padding for the message.\n"
" --button-border-size size Thickness for the button border.\n" " --details-border-size size Thickness for the details border.\n"
" --button-gap gap Size of the gap between buttons\n" " --button-border-size size Thickness for the button border.\n"
" --button-dismiss-gap gap Size of the gap for dismiss button.\n" " --button-gap gap Size of the gap between buttons\n"
" --button-margin-right margin Margin from dismiss button to edge.\n" " --button-dismiss-gap gap Size of the gap for dismiss button.\n"
" --button-padding padding Padding for the button text.\n"; " --button-margin-right margin Margin from dismiss button to edge.\n"
" --button-padding padding Padding for the button text.\n";
optind = 1; optind = 1;
while (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); fprintf(stderr, "Invalid text color: %s", optarg);
} }
break; 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 case TO_THICK_BAR_BORDER: // Bottom border thickness
if (type) { if (type) {
type->bar_border_thickness = strtol(optarg, NULL, 0); type->bar_border_thickness = strtol(optarg, NULL, 0);

View file

@ -47,7 +47,7 @@ static void render_details_scroll_button(cairo_t *cairo,
button->width - (border * 2), button->height - (border * 2)); button->width - (border * 2), button->height - (border * 2));
cairo_fill(cairo); 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, cairo_move_to(cairo, button->x + border + padding,
button->y + border + (button->height - text_height) / 2); button->y + border + (button->height - text_height) / 2);
pango_printf(cairo, swaynag->type->font, swaynag->scale, true, 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); button->width, button->height);
cairo_fill(cairo); 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); cairo_move_to(cairo, button->x + padding, button->y + padding);
pango_printf(cairo, swaynag->type->font, swaynag->scale, true, pango_printf(cairo, swaynag->type->font, swaynag->scale, true,
"%s", button->text); "%s", button->text);

View file

@ -97,6 +97,9 @@ _swaynag_ [options...]
*--text* <RRGGBB[AA]> *--text* <RRGGBB[AA]>
Set the text color. Set the text color.
*--button-text* <RRGGBB[AA]>
Set the button text color.
*--border-bottom-size* <size> *--border-bottom-size* <size>
Set the thickness of the bottom border. Set the thickness of the bottom border.

View file

@ -42,6 +42,9 @@ colors can be set:
*text=<color>* *text=<color>*
The color of the text. The color of the text.
*button-text=<color>*
The color of the button text.
The following sizing options can also be set: The following sizing options can also be set:
*border-bottom-size=<size>* *border-bottom-size=<size>*

View file

@ -38,6 +38,7 @@ void swaynag_types_add_default(list_t *types) {
type_defaults->button_background = 0x333333FF; type_defaults->button_background = 0x333333FF;
type_defaults->background = 0x323232FF; type_defaults->background = 0x323232FF;
type_defaults->text = 0xFFFFFFFF; type_defaults->text = 0xFFFFFFFF;
type_defaults->button_text = 0xFFFFFFFF;
type_defaults->border = 0x222222FF; type_defaults->border = 0x222222FF;
type_defaults->border_bottom = 0x444444FF; type_defaults->border_bottom = 0x444444FF;
type_defaults->bar_border_thickness = 2; 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->button_background = 0x680A0AFF;
type_error->background = 0x900000FF; type_error->background = 0x900000FF;
type_error->text = 0xFFFFFFFF; type_error->text = 0xFFFFFFFF;
type_error->button_text = 0xFFFFFFFF;
type_error->border = 0xD92424FF; type_error->border = 0xD92424FF;
type_error->border_bottom = 0x470909FF; type_error->border_bottom = 0x470909FF;
list_add(types, type_error); list_add(types, type_error);
@ -62,6 +64,7 @@ void swaynag_types_add_default(list_t *types) {
type_warning->button_background = 0xFFC100FF; type_warning->button_background = 0xFFC100FF;
type_warning->background = 0xFFA800FF; type_warning->background = 0xFFA800FF;
type_warning->text = 0x000000FF; type_warning->text = 0x000000FF;
type_warning->button_text = 0x000000FF;
type_warning->border = 0xAB7100FF; type_warning->border = 0xAB7100FF;
type_warning->border_bottom = 0xAB7100FF; type_warning->border_bottom = 0xAB7100FF;
list_add(types, type_warning); 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; dest->text = src->text;
} }
if (src->button_text > 0) {
dest->button_text = src->button_text;
}
if (src->border > 0) { if (src->border > 0) {
dest->border = src->border; dest->border = src->border;
} }