]> git.armaanb.net Git - slock.git/commitdiff
Option to not show failure color on clear
authorNick Currier <nick.currier@gmail.com>
Wed, 6 May 2015 16:18:50 +0000 (10:18 -0600)
committerMarkus Teich <markus.teich@stusta.mhn.de>
Fri, 8 May 2015 14:44:06 +0000 (16:44 +0200)
config.def.h
slock.c

index 4bccb5da900f5a805890ac3f0b8c0eb44d45f6f4..fca0ae0aaf96d50a157d98743abf3ac44cf91e38 100644 (file)
@@ -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 6502c86157ec2022f8ca2a3782a5e4880412000a..1551a9ec30983a9f1b76c1276a4f82053c154684 100644 (file)
--- 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);
                                }
                        }