aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h1
-rw-r--r--slock.c16
2 files changed, 13 insertions, 4 deletions
diff --git a/config.h b/config.h
index ceceeb0..6991d6b 100644
--- a/config.h
+++ b/config.h
@@ -6,6 +6,7 @@ static const char *colorname[NUMCOLS] = {
6 [INIT] = "black", /* after initialization */ 6 [INIT] = "black", /* after initialization */
7 [INPUT] = "#005577", /* during input */ 7 [INPUT] = "#005577", /* during input */
8 [FAILED] = "#CC3333", /* wrong password */ 8 [FAILED] = "#CC3333", /* wrong password */
9 [CAPS] = "red", /* CapsLock on */
9}; 10};
10 11
11/* treat a cleared input like a wrong password (color) */ 12/* treat a cleared input like a wrong password (color) */
diff --git a/slock.c b/slock.c
index efbe833..b8be41a 100644
--- a/slock.c
+++ b/slock.c
@@ -24,7 +24,7 @@
24#include <X11/Xutil.h> 24#include <X11/Xutil.h>
25#include <X11/Xft/Xft.h> 25#include <X11/Xft/Xft.h>
26#include <Imlib2.h> 26#include <Imlib2.h>
27 27#include <X11/XKBlib.h>
28#include "arg.h" 28#include "arg.h"
29#include "util.h" 29#include "util.h"
30 30
@@ -34,6 +34,7 @@ enum {
34 INIT, 34 INIT,
35 INPUT, 35 INPUT,
36 FAILED, 36 FAILED,
37 CAPS,
37 NUMCOLS 38 NUMCOLS
38}; 39};
39 40
@@ -172,16 +173,20 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
172{ 173{
173 XRRScreenChangeNotifyEvent *rre; 174 XRRScreenChangeNotifyEvent *rre;
174 char buf[32], passwd[256], *inputhash; 175 char buf[32], passwd[256], *inputhash;
175 int num, screen, running, failure, oldc; 176 int caps, num, screen, running, failure, oldc;
176 unsigned int len, color; 177 unsigned int len, color, indicators;
177 KeySym ksym; 178 KeySym ksym;
178 XEvent ev; 179 XEvent ev;
179 180
180 len = 0; 181 len = 0;
182 caps = 0;
181 running = 1; 183 running = 1;
182 failure = 0; 184 failure = 0;
183 oldc = INIT; 185 oldc = INIT;
184 186
187 if (!XkbGetIndicatorState(dpy, XkbUseCoreKbd, &indicators))
188 caps = indicators & 1;
189
185 while (running && !XNextEvent(dpy, &ev)) { 190 while (running && !XNextEvent(dpy, &ev)) {
186 if (ev.type == KeyPress) { 191 if (ev.type == KeyPress) {
187 explicit_bzero(&buf, sizeof(buf)); 192 explicit_bzero(&buf, sizeof(buf));
@@ -221,6 +226,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
221 if (len) 226 if (len)
222 passwd[--len] = '\0'; 227 passwd[--len] = '\0';
223 break; 228 break;
229 case XK_Caps_Lock:
230 caps = !caps;
231 break;
224 default: 232 default:
225 if (num && !iscntrl((int)buf[0]) && 233 if (num && !iscntrl((int)buf[0]) &&
226 (len + num < sizeof(passwd))) { 234 (len + num < sizeof(passwd))) {
@@ -229,7 +237,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
229 } 237 }
230 break; 238 break;
231 } 239 }
232 color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT); 240 color = len ? (caps ? CAPS : INPUT) : (failure || failonclear ? FAILED : INIT);
233 if (running && oldc != color) { 241 if (running && oldc != color) {
234 for (screen = 0; screen < nscreens; screen++) { 242 for (screen = 0; screen < nscreens; screen++) {
235 drawlogo(dpy, locks[screen], color); 243 drawlogo(dpy, locks[screen], color);