This is so people who have the INIT color set to black but the FAILURE color set to something else can still have their monitor black out after failing to unlock, without having to unlock and lock again.
Also makes sense because pushing Esc isn't really a failure, but a purposefully aborted unlock attempt, so the background shouldn't be set to FAILURE. (Note: let me know if you prefer to pull from Github, I'm new to the list.) --- slock.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slock.c b/slock.c index c9cdee2..48f917f 100644 --- a/slock.c +++ b/slock.c @@ -125,6 +125,7 @@ readpw(Display *dpy, const char *pws) KeySym ksym; XEvent ev; static int oldc = INIT; + Bool reset = False; len = 0; running = True; @@ -165,6 +166,7 @@ readpw(Display *dpy, const char *pws) break; case XK_Escape: len = 0; + reset = True; break; case XK_BackSpace: if (len) @@ -177,7 +179,12 @@ readpw(Display *dpy, const char *pws) } break; } - color = len ? INPUT : (failure || failonclear ? FAILED : INIT); + if (reset) { + color = INIT; + reset = False; + } else { + color = len ? INPUT : (failure || failonclear ? FAILED : INIT); + } if (running && oldc != color) { for (screen = 0; screen < nscreens; screen++) { XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[color]); -- 2.8.0