0001-patch-capscolor.patch (2437B)
1https://tools.suckless.org/slock/patches/capscolor/ 2 3From f85739f8f7a10713716ca952872b3def9e6055cf Mon Sep 17 00:00:00 2001 4From: Dash Eclipse <dashezup@disroot.org> 5Date: Thu, 16 Jul 2020 10:14:59 +0000 6Subject: [PATCH 1/3] patch capscolor 7 8--- 9 config.def.h | 1 + 10 slock.c | 15 ++++++++++++--- 11 2 files changed, 13 insertions(+), 3 deletions(-) 12 13diff --git a/config.def.h b/config.def.h 14index 9855e21..6288856 100644 15--- a/config.def.h 16+++ b/config.def.h 17@@ -6,6 +6,7 @@ static const char *colorname[NUMCOLS] = { 18 [INIT] = "black", /* after initialization */ 19 [INPUT] = "#005577", /* during input */ 20 [FAILED] = "#CC3333", /* wrong password */ 21+ [CAPS] = "red", /* CapsLock on */ 22 }; 23 24 /* treat a cleared input like a wrong password (color) */ 25diff --git a/slock.c b/slock.c 26index d2f0886..ffcb4a3 100644 27--- a/slock.c 28+++ b/slock.c 29@@ -18,6 +18,7 @@ 30 #include <X11/keysym.h> 31 #include <X11/Xlib.h> 32 #include <X11/Xutil.h> 33+#include <X11/XKBlib.h> 34 35 #include "arg.h" 36 #include "util.h" 37@@ -28,6 +29,7 @@ enum { 38 INIT, 39 INPUT, 40 FAILED, 41+ CAPS, 42 NUMCOLS 43 }; 44 45@@ -130,16 +132,20 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, 46 { 47 XRRScreenChangeNotifyEvent *rre; 48 char buf[32], passwd[256], *inputhash; 49- int num, screen, running, failure, oldc; 50- unsigned int len, color; 51+ int caps, num, screen, running, failure, oldc; 52+ unsigned int len, color, indicators; 53 KeySym ksym; 54 XEvent ev; 55 56 len = 0; 57+ caps = 0; 58 running = 1; 59 failure = 0; 60 oldc = INIT; 61 62+ if (!XkbGetIndicatorState(dpy, XkbUseCoreKbd, &indicators)) 63+ caps = indicators & 1; 64+ 65 while (running && !XNextEvent(dpy, &ev)) { 66 if (ev.type == KeyPress) { 67 explicit_bzero(&buf, sizeof(buf)); 68@@ -179,6 +185,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, 69 if (len) 70 passwd[len--] = '\0'; 71 break; 72+ case XK_Caps_Lock: 73+ caps = !caps; 74+ break; 75 default: 76 if (num && !iscntrl((int)buf[0]) && 77 (len + num < sizeof(passwd))) { 78@@ -187,7 +196,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens, 79 } 80 break; 81 } 82- color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT); 83+ color = len ? (caps ? CAPS : INPUT) : (failure || failonclear ? FAILED : INIT); 84 if (running && oldc != color) { 85 for (screen = 0; screen < nscreens; screen++) { 86 XSetWindowBackground(dpy, 87-- 882.27.0 89