commit b16a021a15ed18c501b7e2ffd03a5d7b85cf9dfd
parent 3fd2e2a5626d8c625919a79103937695171a7c52
Author: catboomer <catb00mer@proton.me>
Date: Mon, 12 Aug 2024 18:20:56 -0500
[slock][patch][passthrough] added patch
Diffstat:
2 files changed, 133 insertions(+), 0 deletions(-)
diff --git a/tools.suckless.org/slock/patches/passthrough/index.md b/tools.suckless.org/slock/patches/passthrough/index.md
@@ -0,0 +1,29 @@
+Passthrough
+===========
+
+Description
+-----------
+Adds a new table to `config.def.h` that allows you to specify binds that are
+allowed to pass through slock.
+
+Important! Much like the `mediakeys` patch, dwm will require a small patch to
+get this working. From `mediakeys`:
+
+If you are using dwm for key bindings, in your `dwm.c` file, go to the
+`setup` function to the line with `wa.event_mask =` and add `|KeyPressMask`
+
+```c
+ wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
+ |ButtonPressMask|PointerMotionMask|EnterWindowMask
+ |LeaveWindowMask|StructureNotifyMask|PropertyChangeMask|KeyPressMask;
+```
+
+
+Download
+--------
+* [slock-passthrough-20240812-809d3c0.diff](slock-passthrough-20240812-809d3c0.diff)
+
+
+Authors
+-------
+* Catboomer <catb00mer@proton.me>
diff --git a/tools.suckless.org/slock/patches/passthrough/slock-passthrough-20240812-809d3c0.diff b/tools.suckless.org/slock/patches/passthrough/slock-passthrough-20240812-809d3c0.diff
@@ -0,0 +1,104 @@
+From 809d3c01cfdc8c5bf7eb37e5d3ade59b0947cab3 Mon Sep 17 00:00:00 2001
+From: catboomer <catb00mer@proton.me>
+Date: Mon, 12 Aug 2024 17:55:30 -0500
+Subject: [PATCH] [PATCH] passthrough: adds table to config.h to permit certain
+ keys to pass through slock
+
+---
+ config.def.h | 15 +++++++++++++++
+ slock.c | 28 +++++++++++++++++++++++++++-
+ 2 files changed, 42 insertions(+), 1 deletion(-)
+
+diff --git a/config.def.h b/config.def.h
+index 9855e21..5b2ff78 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -10,3 +10,18 @@ static const char *colorname[NUMCOLS] = {
+
+ /* treat a cleared input like a wrong password (color) */
+ static const int failonclear = 1;
++
++#include <X11/XF86keysym.h>
++
++static const Passthrough passthroughs[] = {
++ /* Modifier Key */
++ { 0, XF86XK_AudioRaiseVolume },
++ { 0, XF86XK_AudioLowerVolume },
++ { 0, XF86XK_AudioMute },
++ { 0, XF86XK_AudioPause },
++ { 0, XF86XK_AudioStop },
++ { 0, XF86XK_AudioNext },
++ { 0, XF86XK_AudioPrev },
++ { 0, XF86XK_MonBrightnessUp },
++ { 0, XF86XK_MonBrightnessDown },
++};
+diff --git a/slock.c b/slock.c
+index 5ae738c..522a226 100644
+--- a/slock.c
++++ b/slock.c
+@@ -22,6 +22,11 @@
+ #include "arg.h"
+ #include "util.h"
+
++#include <X11/XF86keysym.h>
++#define LENGTH(X) (sizeof X / sizeof X[0])
++#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
++
++static unsigned int numlockmask = 0;
+ char *argv0;
+
+ enum {
+@@ -31,6 +36,11 @@ enum {
+ NUMCOLS
+ };
+
++typedef struct {
++ unsigned int mod;
++ KeySym keysym;
++} Passthrough;
++
+ struct lock {
+ int screen;
+ Window root, win;
+@@ -130,7 +140,7 @@ 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;
++ int num, screen, running, failure, oldc, i, passing;
+ unsigned int len, color;
+ KeySym ksym;
+ XEvent ev;
+@@ -156,6 +166,20 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
+ IsPFKey(ksym) ||
+ IsPrivateKeypadKey(ksym))
+ continue;
++
++ passing = 0;
++ for (i = 0; i < LENGTH(passthroughs); i++) {
++ if (ksym == passthroughs[i].keysym &&
++ CLEANMASK(passthroughs[i].mod) == CLEANMASK(ev.xkey.state)) {
++ passing = 1;
++ XSendEvent(dpy, DefaultRootWindow(dpy), True, KeyPressMask, &ev);
++ break;
++ }
++ }
++
++ if(passing)
++ continue;
++
+ switch (ksym) {
+ case XK_Return:
+ passwd[len] = '\0';
+@@ -184,6 +208,8 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
+ (len + num < sizeof(passwd))) {
+ memcpy(passwd + len, buf, num);
+ len += num;
++ } else {
++ continue; /* Don't trigger fail screen when pressing control characters */
+ }
+ break;
+ }
+--
+2.46.0
+