Add arguments to define different text color for pressed and swiped keys

Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
This commit is contained in:
Pachulke
2026-03-06 07:18:42 +00:00
committed by Maarten van Gompel
parent 4366d88eca
commit e67a5afce9
4 changed files with 52 additions and 3 deletions

View File

@@ -14,6 +14,8 @@ struct clr_scheme schemes[] = {
.high = {.bgra = {100, 100, 100, transparency}},
.swipe = {.bgra = {100, 255, 100, 64}},
.text = {.color = UINT32_MAX},
.text_press = {.color = UINT32_MAX},
.text_swipe = {.color = UINT32_MAX},
.font = DEFAULT_FONT,
.rounding = DEFAULT_ROUNDING,
},
@@ -23,6 +25,8 @@ struct clr_scheme schemes[] = {
.fg = {.bgra = {32, 32, 32, transparency}},
.high = {.bgra = {100, 100, 100, transparency}},
.swipe = {.bgra = {100, 255, 100, 64}},
.text_press = {.color = UINT32_MAX},
.text_swipe = {.color = UINT32_MAX},
.text = {.color = UINT32_MAX},
.font = DEFAULT_FONT,
.rounding = DEFAULT_ROUNDING,

View File

@@ -616,19 +616,26 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
case Unpress:
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
scheme->fg, scheme->rounding);
drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h,
KBD_KEY_BORDER, label, scheme->font_description);
break;
case Press:
draw_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
scheme->high, scheme->rounding);
drw_draw_text(kb->surf, scheme->text_press, k->x, k->y, k->w, k->h,
KBD_KEY_BORDER, label, scheme->font_description);
break;
case Swipe:
draw_over_inset(kb->surf, k->x, k->y, k->w, k->h, KBD_KEY_BORDER,
scheme->swipe, scheme->rounding);
drw_draw_text(kb->surf, scheme->text_swipe, k->x, k->y, k->w, k->h,
KBD_KEY_BORDER, label, scheme->font_description);
break;
}
default:
drw_draw_text(kb->surf, scheme->text, k->x, k->y, k->w, k->h,
KBD_KEY_BORDER, label, scheme->font_description);
}
if (type == Press || type == Unpress) {
kbd_clear_last_popup(kb);
@@ -642,7 +649,7 @@ kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
kb->last_popup_y, k->w, k->h, scheme->rounding);
draw_inset(kb->popup_surf, k->x, kb->last_popup_y, k->w, k->h,
KBD_KEY_BORDER, scheme->high, scheme->rounding);
drw_draw_text(kb->popup_surf, scheme->text, k->x, kb->last_popup_y,
drw_draw_text(kb->popup_surf, scheme->text_press, k->x, kb->last_popup_y,
k->w, k->h, KBD_KEY_BORDER, label,
scheme->font_description);
}

View File

@@ -54,6 +54,8 @@ struct clr_scheme {
Color high;
Color swipe;
Color text;
Color text_press;
Color text_swipe;
char *font;
int rounding;
PangoFontDescription *font_description;

36
main.c
View File

@@ -618,6 +618,14 @@ usage(char *argv0)
fprintf(stderr, " --text [rrggbb|aa] - Set color of text on keys\n");
fprintf(stderr,
" --text-sp [rrggbb|aa] - Set color of text on special keys\n");
fprintf(stderr,
" --text-press [rrggbb|aa] - Set color of text on pressed keys\n");
fprintf(stderr,
" --text-press-sp [rrggbb|aa] - Set color of text on pressed special keys\n");
fprintf(stderr,
" --text-swipe [rrggbb|aa] - Set color of text on swiped keys\n");
fprintf(stderr,
" --text-swipe-sp [rrggbb|aa] - Set color of text on swiped special keys\n");
fprintf(stderr,
" --list-layers - Print the list of available layers\n");
fprintf(stderr,
@@ -902,6 +910,34 @@ main(int argc, char **argv)
exit(1);
}
set_kbd_colors(keyboard.schemes[1].text.bgra, argv[++i]);
} else if ((!strcmp(argv[i], "-text-press")) ||
(!strcmp(argv[i], "--text-press"))) {
if (i >= argc - 1) {
usage(argv[0]);
exit(1);
}
set_kbd_colors(keyboard.schemes[0].text_press.bgra, argv[++i]);
} else if ((!strcmp(argv[i], "-text-press-sp")) ||
(!strcmp(argv[i], "--text-press-sp"))) {
if (i >= argc - 1) {
usage(argv[0]);
exit(1);
}
set_kbd_colors(keyboard.schemes[1].text_press.bgra, argv[++i]);
} else if ((!strcmp(argv[i], "-text-swipe")) ||
(!strcmp(argv[i], "--text-swipe"))) {
if (i >= argc - 1) {
usage(argv[0]);
exit(1);
}
set_kbd_colors(keyboard.schemes[0].text_swipe.bgra, argv[++i]);
} else if ((!strcmp(argv[i], "-text-swipe-sp")) ||
(!strcmp(argv[i], "--text-swipe-sp"))) {
if (i >= argc - 1) {
usage(argv[0]);
exit(1);
}
set_kbd_colors(keyboard.schemes[1].text_swipe.bgra, argv[++i]);
} else if (!strcmp(argv[i], "-H")) {
if (i >= argc - 1) {
usage(argv[0]);