summaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-01-29 14:48:00 -0500
committerGitHub <noreply@github.com>2019-01-29 14:48:00 -0500
commiteffdea523158c8e30f7654a87402df155a2229ad (patch)
treeaefcf80e26de3c590bbedf53244e41e163b30916 /render.c
parentecc8402c43262e7d92ffa238e4da609c174f55a0 (diff)
parent40e9098a741b1a213b55cd6a400aa1c7eb4f47e8 (diff)
Merge pull request #39 from bendooru/show-failed-attempts1.3
Add option show-failed-attempts
Diffstat (limited to 'render.c')
-rw-r--r--render.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/render.c b/render.c
index 25b75f0..cf6de2a 100644
--- a/render.c
+++ b/render.c
@@ -86,6 +86,7 @@ void render_frame(struct swaylock_surface *surface) {
// Draw a message
char *text = NULL;
+ char attempts[4]; // like i3lock: count no more than 999
set_color_for_state(cairo, state, &state->args.colors.text);
cairo_select_font_face(cairo, state->args.font,
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
@@ -103,8 +104,17 @@ void render_frame(struct swaylock_surface *surface) {
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";
+ } else if (state->args.show_failed_attempts &&
+ state->failed_attempts > 0) {
+ if (state->failed_attempts > 999) {
+ text = "999+";
+ } else {
+ snprintf(attempts, sizeof(attempts), "%d", state->failed_attempts);
+ text = attempts;
+ }
}
break;
default: