commit fe2d23e7280bc6834c82db5cd5a654859ea72a3a
Author: Adrian Amaglio <[email protected]>
Date: Sun Oct 2 14:40:13 2022 +0200
[slock][patch][auto-timeout] Fix previous update
The previus update I made was boggus : the timout could not be
reached unless an X event append.
diff --git
a/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
b/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
index dc073191..974de32e 100644
---
a/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
+++
b/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
@@ -16,7 +16,7 @@ index 9855e21..354980b 100644
+/* command to be run after [timeoffset] seconds has passed */
+static const char *command = "doas poweroff";
diff --git a/slock.c b/slock.c
-index 5ae738c..5ece0ae 100644
+index 5ae738c..7644bd9 100644
--- a/slock.c
+++ b/slock.c
@@ -19,11 +19,16 @@
@@ -36,10 +36,21 @@ index 5ae738c..5ece0ae 100644
enum {
INIT,
INPUT,
-@@ -216,6 +221,16 @@ readpw(Display *dpy, struct xrandr *rr, struct lock
**locks, int nscreens,
- for (screen = 0; screen < nscreens; screen++)
- XRaiseWindow(dpy, locks[screen]->win);
- }
+@@ -140,7 +145,9 @@ readpw(Display *dpy, struct xrandr *rr, struct lock
**locks, int nscreens,
+ failure = 0;
+ oldc = INIT;
+
+- while (running && !XNextEvent(dpy, &ev)) {
++ while (running) {
++ while (XPending(dpy)) {
++ XNextEvent(dpy, &ev);
+ if (ev.type == KeyPress) {
+ explicit_bzero(&buf, sizeof(buf));
+ num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym,
0);
+@@ -217,6 +224,17 @@ readpw(Display *dpy, struct xrandr *rr, struct lock
**locks, int nscreens,
+ XRaiseWindow(dpy, locks[screen]->win);
+ }
+ }
+
+ time_t currenttime;
+ time(¤ttime);
@@ -50,10 +61,11 @@ index 5ae738c..5ece0ae 100644
+ system(command);
+ }
+ }
- }
++ }
}
-@@ -229,6 +244,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
+ static struct lock *
+@@ -229,6 +247,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
XSetWindowAttributes wa;
Cursor invisible;