[wiki] [sites] [slock][patch][passthrough] added patch || catboomer

From: <git_AT_suckless.org>
Date: Tue, 13 Aug 2024 01:22:55 +0200

commit b16a021a15ed18c501b7e2ffd03a5d7b85cf9dfd
Author: catboomer <catb00mer_AT_proton.me>
Date: Mon Aug 12 18:20:56 2024 -0500

    [slock][patch][passthrough] added patch

diff --git a/tools.suckless.org/slock/patches/passthrough/index.md b/tools.suckless.org/slock/patches/passthrough/index.md
new file mode 100644
index 00000000..f6a832b2
--- /dev/null
+++ b/tools.suckless.org/slock/patches/passthrough/index.md
_AT_@ -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_AT_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
new file mode 100644
index 00000000..bc4c2bc6
--- /dev/null
+++ b/tools.suckless.org/slock/patches/passthrough/slock-passthrough-20240812-809d3c0.diff
_AT_@ -0,0 +1,104 @@
+From 809d3c01cfdc8c5bf7eb37e5d3ade59b0947cab3 Mon Sep 17 00:00:00 2001
+From: catboomer <catb00mer_AT_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
+_AT_@ -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
+_AT_@ -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 {
+_AT_@ -31,6 +36,11 @@ enum {
+ NUMCOLS
+ };
+
++typedef struct {
++ unsigned int mod;
++ KeySym keysym;
++} Passthrough;
++
+ struct lock {
+ int screen;
+ Window root, win;
+_AT_@ -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;
+_AT_@ -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] = '+_AT_@ -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
+
Received on Tue Aug 13 2024 - 01:22:55 CEST

This archive was generated by hypermail 2.3.0 : Tue Aug 13 2024 - 01:24:50 CEST