1
0
mirror of https://github.com/tiyn/slock.git synced 2026-02-22 07:14:48 +01:00

added capscolor patch to master

This commit is contained in:
2023-10-26 02:57:38 +02:00
3 changed files with 104 additions and 6 deletions

15
slock.c
View File

@@ -24,6 +24,7 @@
#include <X11/Xutil.h>
#include <Imlib2.h>
#include <X11/Xft/Xft.h>
#include <X11/XKBlib.h>
#include "arg.h"
#include "util.h"
@@ -34,6 +35,7 @@ enum {
INIT,
INPUT,
FAILED,
CAPS,
NUMCOLS
};
@@ -166,16 +168,20 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
{
XRRScreenChangeNotifyEvent *rre;
char buf[32], passwd[256], *inputhash;
int num, screen, running, failure, oldc;
unsigned int len, color;
int caps, num, screen, running, failure, oldc;
unsigned int len, color, indicators;
KeySym ksym;
XEvent ev;
len = 0;
caps = 0;
running = 1;
failure = 0;
oldc = INIT;
if (!XkbGetIndicatorState(dpy, XkbUseCoreKbd, &indicators))
caps = indicators & 1;
while (running && !XNextEvent(dpy, &ev)) {
if (ev.type == KeyPress) {
explicit_bzero(&buf, sizeof(buf));
@@ -215,6 +221,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
if (len)
passwd[--len] = '\0';
break;
case XK_Caps_Lock:
caps = !caps;
break;
default:
if (controlkeyclear && iscntrl((int)buf[0]))
continue;
@@ -224,7 +233,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
}
break;
}
color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT);
color = len ? (caps ? CAPS : INPUT) : (failure || failonclear ? FAILED : INIT);
if (running && oldc != color) {
for (screen = 0; screen < nscreens; screen++) {
if (locks[screen]->bgmap)