commit a22244b184ca1a17576a944a8e4db194bc0e45f5
parent e483e736c9bc4a7c5d98ece27147f58056f783c1
Author: Alexander Balgavy <alexander.balgavy@spaceapplications.com>
Date: Thu, 2 Nov 2023 16:59:36 +0100
control-clear patch
https://tools.suckless.org/slock/patches/control-clear/slock-git-20161012-control-clear.diff
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -11,3 +11,6 @@ static const char *colorname[NUMCOLS] = {
/* treat a cleared input like a wrong password (color) */
static const int failonclear = 1;
+
+/* allow control key to trigger fail on clear */
+static const int controlkeyclear = 0;
diff --git a/slock.c b/slock.c
@@ -181,8 +181,11 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
passwd[--len] = '\0';
break;
default:
- if (num && !iscntrl((int)buf[0]) &&
- (len + num < sizeof(passwd))) {
+ // if (num && !iscntrl((int)buf[0]) &&
+ // (len + num < sizeof(passwd))) {
+ if (controlkeyclear && iscntrl((int)buf[0]))
+ continue;
+ if (num && (len + num < sizeof(passwd))) {
memcpy(passwd + len, buf, num);
len += num;
}