diff --git a/completions/bash/swaylock b/completions/bash/swaylock index 713fb4c0d..4c661f94a 100644 --- a/completions/bash/swaylock +++ b/completions/bash/swaylock @@ -78,6 +78,10 @@ _swaylock() --text-color --text-ver-color --text-wrong-color + --text-clear + --text-caps-lock + --text-ver + --text-wrong --tiling --version ) diff --git a/completions/fish/swaylock.fish b/completions/fish/swaylock.fish index 41416a393..82c16af98 100644 --- a/completions/fish/swaylock.fish +++ b/completions/fish/swaylock.fish @@ -51,5 +51,9 @@ complete -c swaylock -l text-clear-color --description "Sets the colo complete -c swaylock -l text-color --description "Sets the color of the text." complete -c swaylock -l text-ver-color --description "Sets the color of the text when verifying." complete -c swaylock -l text-wrong-color --description "Sets the color of the text when invalid." +complete -c swaylock -l text-clear --description "Sets the text when cleared." +complete -c swaylock -l text-caps-lock --description "Sets the text when Caps Lock is active." +complete -c swaylock -l text-ver --description "Sets the text when verifying." +complete -c swaylock -l text-wrong --description "Sets 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 9e9f78866..653bb0bb6 100644 --- a/completions/zsh/_swaylock +++ b/completions/zsh/_swaylock @@ -55,5 +55,9 @@ _arguments -s \ '(--text-color)'--text-color'[Sets the color of the text]:color:' \ '(--text-ver-color)'--text-ver-color'[Sets the color of the text when verifying]:color:' \ '(--text-wrong-color)'--text-wrong-color'[Sets the color of the text when invalid]:color:' \ + '(--text-clear)'--text-clear'[Sets the text when cleared]:text:' \ + '(--text-caps-lock)'--text-caps-lock'[Sets the text when Caps Lock is active]:text:' \ + '(--text-ver)'--text-ver'[Sets the text when verifying]:text:' \ + '(--text-wrong)'--text-wrong'[Sets the text when invalid]:text:' \ '(--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 30f91176f..9bddbc6e5 100644 --- a/include/swaylock.h +++ b/include/swaylock.h @@ -43,8 +43,16 @@ struct swaylock_colors { struct swaylock_colorset text; }; +struct swaylock_texts { + char *clear; + char *caps_lock; + char *verifying; + char *wrong; +}; + struct swaylock_args { struct swaylock_colors colors; + struct swaylock_texts texts; enum background_mode mode; char *font; uint32_t font_size; diff --git a/main.c b/main.c index 7f7bd6cb3..7357c5626 100644 --- a/main.c +++ b/main.c @@ -548,6 +548,13 @@ static void set_default_colors(struct swaylock_colors *colors) { }; } +static void set_default_texts(struct swaylock_texts *texts) { + texts->clear = "Cleared"; + texts->caps_lock = "Caps lock"; + texts->verifying = "Verifying"; + texts->wrong = "Wrong"; +} + enum line_mode { LM_LINE, LM_INSIDE, @@ -592,6 +599,10 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, LO_TEXT_CAPS_LOCK_COLOR, LO_TEXT_VER_COLOR, LO_TEXT_WRONG_COLOR, + LO_TEXT_CLEAR, + LO_TEXT_CAPS_LOCK, + LO_TEXT_VER, + LO_TEXT_WRONG, }; static struct option long_options[] = { @@ -648,6 +659,10 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, {"text-caps-lock-color", required_argument, NULL, LO_TEXT_CAPS_LOCK_COLOR}, {"text-ver-color", required_argument, NULL, LO_TEXT_VER_COLOR}, {"text-wrong-color", required_argument, NULL, LO_TEXT_WRONG_COLOR}, + {"text-clear", required_argument, NULL, LO_TEXT_CLEAR}, + {"text-caps-lock", required_argument, NULL, LO_TEXT_CAPS_LOCK}, + {"text-ver", required_argument, NULL, LO_TEXT_VER}, + {"text-wrong", required_argument, NULL, LO_TEXT_WRONG}, {0, 0, 0, 0} }; @@ -768,6 +783,14 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, "Sets the color of the text when verifying.\n" " --text-wrong-color " "Sets the color of the text when invalid.\n" + " --text-clear " + "Sets the text when cleared.\n" + " --text-caps-lock " + "Sets the text when Caps Lock is active.\n" + " --text-ver " + "Sets the text when verifying.\n" + " --text-wrong " + "Sets the text when invalid.\n" "\n" "All options are of the form .\n"; @@ -1044,6 +1067,26 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state, state->args.colors.text.wrong = parse_color(optarg); } break; + case LO_TEXT_CLEAR: + if (state) { + state->args.texts.clear = optarg; + } + break; + case LO_TEXT_CAPS_LOCK: + if (state) { + state->args.texts.caps_lock = optarg; + } + break; + case LO_TEXT_VER: + if (state) { + state->args.texts.verifying = optarg; + } + break; + case LO_TEXT_WRONG: + if (state) { + state->args.texts.wrong = optarg; + } + break; default: fprintf(stderr, "%s", usage); return 1; @@ -1177,6 +1220,7 @@ int main(int argc, char **argv) { }; wl_list_init(&state.images); set_default_colors(&state.args.colors); + set_default_texts(&state.args.texts); char *config_path = NULL; int result = parse_options(argc, argv, NULL, NULL, &config_path); diff --git a/render.c b/render.c index 3dec74364..6714a03a3 100644 --- a/render.c +++ b/render.c @@ -163,20 +163,20 @@ void render_frame(struct swaylock_surface *surface) { } switch (state->auth_state) { case AUTH_STATE_VALIDATING: - text = "verifying"; + text = state->args.texts.verifying; break; case AUTH_STATE_INVALID: - text = "wrong"; + text = state->args.texts.wrong; break; case AUTH_STATE_CLEAR: - text = "cleared"; + text = state->args.texts.clear; 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.texts.caps_lock; } else if (state->args.show_failed_attempts && state->failed_attempts > 0) { if (state->failed_attempts > 999) {