diff --git a/completions/bash/swaylock b/completions/bash/swaylock index e149353e..87fc617f 100644 --- a/completions/bash/swaylock +++ b/completions/bash/swaylock @@ -74,10 +74,14 @@ _swaylock() --separator-color --show-failed-attempts --show-keyboard-layout + --text-caps-lock --text-caps-lock-color + --text-clear --text-clear-color --text-color + --text-ver --text-ver-color + --text-wrong --text-wrong-color --tiling --version diff --git a/completions/fish/swaylock.fish b/completions/fish/swaylock.fish index f73a1ec2..bb25d709 100644 --- a/completions/fish/swaylock.fish +++ b/completions/fish/swaylock.fish @@ -47,10 +47,14 @@ complete -c swaylock -l scaling -s s --description "Image scaling complete -c swaylock -l separator-color --description "Sets the color of the lines that separate highlight segments." complete -c swaylock -l show-failed-attempts -s F --description "Show current count of failed authentication attempts." complete -c swaylock -l show-keyboard-layout -s k --description "Display the current xkb layout while typing." +complete -c swaylock -l text-caps-lock --description "Sets the string displayed when Caps Lock is active." complete -c swaylock -l text-caps-lock-color --description "Sets the color of the text when Caps Lock is active." +complete -c swaylock -l text-clear --description "Sets the string displayed when the password is cleared." complete -c swaylock -l text-clear-color --description "Sets the color of the text when cleared." complete -c swaylock -l text-color --description "Sets the color of the text." +complete -c swaylock -l text-ver --description "Sets the string displayed when the password is being verified." complete -c swaylock -l text-ver-color --description "Sets the color of the text when verifying." +complete -c swaylock -l text-wrong --description "Sets the string displayed when the password is wrong." complete -c swaylock -l text-wrong-color --description "Sets the color of the text when invalid." complete -c swaylock -l tiling -s t --description "Same as --scaling=tile." complete -c swaylock -l version -s v --description "Show the version number and quit." diff --git a/completions/zsh/_swaylock b/completions/zsh/_swaylock index f0302309..6fc2126a 100644 --- a/completions/zsh/_swaylock +++ b/completions/zsh/_swaylock @@ -51,10 +51,14 @@ _arguments -s \ '(--separator-color)'--separator-color'[Sets the color of the lines that separate highlight segments]:color:' \ '(--show-failed-attempts -F)'{--show-failed-attempts,-F}'[Show current count of failed authentication attempts]' \ '(--show-keyboard-layout -k)'{--show-keyboard-layout,-k}'[Display the current xkb layout while typing]' \ + '(--text-caps-lock)'--text-caps-lock'[Sets the string displayed when Caps Lock is active]' \ '(--text-caps-lock-color)'--text-caps-lock-color'[Sets the color of the text when Caps Lock is active]:color:' \ + '(--text-clear)'--text-clear'[Sets the string displayed when the password is cleared]' \ '(--text-clear-color)'--text-clear-color'[Sets the color of the text when cleared]:color:' \ '(--text-color)'--text-color'[Sets the color of the text]:color:' \ + '(--text-ver)'--text-ver'[Sets the string displayed when the password is being verified]' \ '(--text-ver-color)'--text-ver-color'[Sets the color of the text when verifying]:color:' \ + '(--text-wrong)'--text-wrong'[Sets the string displayed when the password is wrong]' \ '(--text-wrong-color)'--text-wrong-color'[Sets the color of the text when invalid]:color:' \ '(--tiling -T)'{--tiling,-T}'[Same as --scaling=tile]' \ '(--version -v)'{--version,-v}'[Show the version number and quit]' diff --git a/include/swaylock.h b/include/swaylock.h index 8d032e9b..de09ce85 100644 --- a/include/swaylock.h +++ b/include/swaylock.h @@ -81,6 +81,11 @@ struct swaylock_args { uint32_t password_grace_period; bool password_grace_no_mouse; bool password_grace_no_touch; + + char *text_cleared; + char *text_caps_lock; + char *text_verifying; + char *text_wrong; }; struct swaylock_password { diff --git a/main.c b/main.c index d560463b..9e055176 100644 --- a/main.c +++ b/main.c @@ -957,9 +957,13 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, LO_RING_WRONG_COLOR, LO_SEP_COLOR, LO_TEXT_COLOR, + LO_TEXT_CLEAR, LO_TEXT_CLEAR_COLOR, + LO_TEXT_CAPS_LOCK, LO_TEXT_CAPS_LOCK_COLOR, + LO_TEXT_VER, LO_TEXT_VER_COLOR, + LO_TEXT_WRONG, LO_TEXT_WRONG_COLOR, LO_EFFECT_BLUR, LO_EFFECT_PIXELATE, @@ -1033,9 +1037,13 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, {"ring-wrong-color", required_argument, NULL, LO_RING_WRONG_COLOR}, {"separator-color", required_argument, NULL, LO_SEP_COLOR}, {"text-color", required_argument, NULL, LO_TEXT_COLOR}, + {"text-clear", required_argument, NULL, LO_TEXT_CLEAR}, {"text-clear-color", required_argument, NULL, LO_TEXT_CLEAR_COLOR}, + {"text-caps-lock", required_argument, NULL, LO_TEXT_CAPS_LOCK}, {"text-caps-lock-color", required_argument, NULL, LO_TEXT_CAPS_LOCK_COLOR}, + {"text-ver", required_argument, NULL, LO_TEXT_VER}, {"text-ver-color", required_argument, NULL, LO_TEXT_VER_COLOR}, + {"text-wrong", required_argument, NULL, LO_TEXT_WRONG}, {"text-wrong-color", required_argument, NULL, LO_TEXT_WRONG_COLOR}, {"effect-blur", required_argument, NULL, LO_EFFECT_BLUR}, {"effect-pixelate", required_argument, NULL, LO_EFFECT_PIXELATE}, @@ -1481,21 +1489,45 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, state->args.colors.text.input = parse_color(optarg); } break; + case LO_TEXT_CLEAR: + if (state) { + free(state->args.text_cleared); + state->args.text_cleared = strdup(optarg); + } + break; case LO_TEXT_CLEAR_COLOR: if (state) { state->args.colors.text.cleared = parse_color(optarg); } break; + case LO_TEXT_CAPS_LOCK: + if (state) { + free(state->args.text_caps_lock); + state->args.text_caps_lock = strdup(optarg); + } + break; case LO_TEXT_CAPS_LOCK_COLOR: if (state) { state->args.colors.text.caps_lock = parse_color(optarg); } break; + case LO_TEXT_VER: + if (state) { + free(state->args.text_verifying); + state->args.text_verifying = strdup(optarg); + } + break; case LO_TEXT_VER_COLOR: if (state) { state->args.colors.text.verifying = parse_color(optarg); } break; + case LO_TEXT_WRONG: + if (state) { + free(state->args.text_wrong); + state->args.text_wrong = strdup(optarg); + } + break; case LO_TEXT_WRONG_COLOR: if (state) { state->args.colors.text.wrong = parse_color(optarg); @@ -1815,6 +1847,11 @@ int main(int argc, char **argv) { .datestr = strdup("%a, %x"), .allow_fade = true, .password_grace_period = 0, + + .text_cleared = strdup("Cleared"), + .text_caps_lock = strdup("Caps Lock"), + .text_verifying = strdup("Verifying"), + .text_wrong = strdup("Wrong"), }; wl_list_init(&state.images); set_default_colors(&state.args.colors); diff --git a/render.c b/render.c index 1519bca9..368a4bca 100644 --- a/render.c +++ b/render.c @@ -254,20 +254,20 @@ void render_frame(struct swaylock_surface *surface) { cairo_set_font_size(cairo, font_size); switch (state->auth_state) { case AUTH_STATE_VALIDATING: - text = "Verifying"; + text = state->args.text_verifying; break; case AUTH_STATE_INVALID: - text = "Wrong"; + text = state->args.text_wrong; break; case AUTH_STATE_CLEAR: - text = "Cleared"; + text = state->args.text_cleared; break; case AUTH_STATE_INPUT: case AUTH_STATE_INPUT_NOP: case AUTH_STATE_BACKSPACE: // Caps Lock has higher priority if (state->xkb.caps_lock && state->args.show_caps_lock_text) { - text = "Caps Lock"; + text = state->args.text_caps_lock; } else if (state->args.show_failed_attempts && state->failed_attempts > 0) { if (state->failed_attempts > 999) { diff --git a/swaylock.1.scd b/swaylock.1.scd index d4dfe7de..98c51062 100644 --- a/swaylock.1.scd +++ b/swaylock.1.scd @@ -214,15 +214,27 @@ Locks your Wayland session. *--text-color* Sets the color of the text. +*--text-clear* + Sets the string displayed when the password is cleared. + *--text-clear-color* Sets the color of the text when cleared. +*--text-caps-lock* + Sets the string displayed when Caps Lock is active. + *--text-caps-lock-color* Sets the color of the text when Caps Lock is active. +*--text-ver* + Sets the string displayed when the password is being verified. + *--text-ver-color* Sets the color of the text when verifying. +*--text-wrong* + Sets the string displayed when the password is wrong. + *--text-wrong-color* Sets the color of the text when invalid.