diff options
author | Nick Currier <nick.currier@gmail.com> | 2015-05-06 10:18:50 -0600 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2015-05-08 16:44:06 +0200 |
commit | b1289f30b79c9c5ea43a9e9c624406d7d0661692 (patch) | |
tree | fb675681cac4c4882e9f9da8c882ec0aeb7ec110 | |
parent | f5ef1b8eb5555da11e81d92d8d05acd4aba1ef40 (diff) |
Option to not show failure color on clear
-rw-r--r-- | config.def.h | 1 | ||||
-rw-r--r-- | 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] = { | |||
3 | "#005577", /* during input */ | 3 | "#005577", /* during input */ |
4 | "#CC3333", /* failed/cleared the input */ | 4 | "#CC3333", /* failed/cleared the input */ |
5 | }; | 5 | }; |
6 | static const Bool failonclear = True; | ||
@@ -26,7 +26,7 @@ | |||
26 | enum { | 26 | enum { |
27 | INIT, | 27 | INIT, |
28 | INPUT, | 28 | INPUT, |
29 | EMPTY, | 29 | FAILED, |
30 | NUMCOLS | 30 | NUMCOLS |
31 | }; | 31 | }; |
32 | 32 | ||
@@ -42,6 +42,7 @@ typedef struct { | |||
42 | static Lock **locks; | 42 | static Lock **locks; |
43 | static int nscreens; | 43 | static int nscreens; |
44 | static Bool running = True; | 44 | static Bool running = True; |
45 | static Bool failure = False; | ||
45 | static Bool rr; | 46 | static Bool rr; |
46 | static int rrevbase; | 47 | static int rrevbase; |
47 | static int rrerrbase; | 48 | static int rrerrbase; |
@@ -153,8 +154,10 @@ readpw(Display *dpy, const char *pws) | |||
153 | #else | 154 | #else |
154 | running = !!strcmp(crypt(passwd, pws), pws); | 155 | running = !!strcmp(crypt(passwd, pws), pws); |
155 | #endif | 156 | #endif |
156 | if (running) | 157 | if (running) { |
157 | XBell(dpy, 100); | 158 | XBell(dpy, 100); |
159 | failure = True; | ||
160 | } | ||
158 | len = 0; | 161 | len = 0; |
159 | break; | 162 | break; |
160 | case XK_Escape: | 163 | case XK_Escape: |
@@ -178,7 +181,7 @@ readpw(Display *dpy, const char *pws) | |||
178 | } | 181 | } |
179 | } else if (llen != 0 && len == 0) { | 182 | } else if (llen != 0 && len == 0) { |
180 | for (screen = 0; screen < nscreens; screen++) { | 183 | for (screen = 0; screen < nscreens; screen++) { |
181 | XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[EMPTY]); | 184 | XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[failure || failonclear ? FAILED : INIT]); |
182 | XClearWindow(dpy, locks[screen]->win); | 185 | XClearWindow(dpy, locks[screen]->win); |
183 | } | 186 | } |
184 | } | 187 | } |