On Wed, May 6, 2015 at 9:20 AM, Markus Teich <markus.te...@stusta.mhn.de> wrote:
> I think the new behaviour actually is a more reasonable default.

I had talked to both sin and dsp about this and they thought it best
to keep the existing behaviour.
However, it's easy enough to change if the consensus is to change the default.

> locks[screen]->colors[failure || failonclear ?  FAILED : INIT]

I've made this change and attached the updated patch.

Thanks,
hexid
From e7faddb33b183e966bc2858d146ab9ba78695377 Mon Sep 17 00:00:00 2001
From: hexid <nick.curr...@gmail.com>
Date: Wed, 6 May 2015 09:34:59 -0600
Subject: [PATCH] Add config option to only show error color after a
 failed login attempt

---
 config.def.h | 1 +
 slock.c      | 9 ++++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/config.def.h b/config.def.h
index 4bccb5d..fca0ae0 100644
--- a/config.def.h
+++ b/config.def.h
@@ -3,3 +3,4 @@ static const char *colorname[NUMCOLS] = {
 	"#005577",   /* during input */
 	"#CC3333",   /* failed/cleared the input */
 };
+static const Bool failonclear = True;
diff --git a/slock.c b/slock.c
index 6502c86..1551a9e 100644
--- a/slock.c
+++ b/slock.c
@@ -26,7 +26,7 @@
 enum {
 	INIT,
 	INPUT,
-	EMPTY,
+	FAILED,
 	NUMCOLS
 };
 
@@ -42,6 +42,7 @@ typedef struct {
 static Lock **locks;
 static int nscreens;
 static Bool running = True;
+static Bool failure = False;
 static Bool rr;
 static int rrevbase;
 static int rrerrbase;
@@ -153,8 +154,10 @@ readpw(Display *dpy, const char *pws)
 #else
 				running = !!strcmp(crypt(passwd, pws), pws);
 #endif
-				if (running)
+				if (running) {
 					XBell(dpy, 100);
+					failure = True;
+				}
 				len = 0;
 				break;
 			case XK_Escape:
@@ -178,7 +181,7 @@ readpw(Display *dpy, const char *pws)
 				}
 			} else if (llen != 0 && len == 0) {
 				for (screen = 0; screen < nscreens; screen++) {
-					XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[EMPTY]);
+					XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]);
 					XClearWindow(dpy, locks[screen]->win);
 				}
 			}
-- 
2.3.7

Reply via email to