[wiki] [sites] [slock][patch][auto-timeout] Updated auto-timeout patch for new slock version || Adrian Amaglio
commit 50bb4969c54facc0c5c136fec30c0d93a86d6260
Author: Adrian Amaglio <adrian_AT_amaglio.fr>
Date: Sun Oct 2 00:06:17 2022 +0200
[slock][patch][auto-timeout] Updated auto-timeout patch for new slock version
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
new file mode 100644
index 00000000..dc073191
--- /dev/null
+++ b/tools.suckless.org/slock/patches/auto-timeout/slock-auto-timeout-20221002-35633d4.diff
_AT_@ -0,0 +1,64 @@
+diff --git a/config.def.h b/config.def.h
+index 9855e21..354980b 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -10,3 +10,12 @@ static const char *colorname[NUMCOLS] = {
+
+ /* treat a cleared input like a wrong password (color) */
+ static const int failonclear = 1;
++
++/* length of time (seconds) until [command] is executed */
++static const int timeoffset = 60;
++
++/* should [command] be run only once? */
++static const int runonce = 0;
++
++/* 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
+--- a/slock.c
++++ b/slock.c
+_AT_@ -19,11 +19,16 @@
+ #include <X11/Xlib.h>
+ #include <X11/Xutil.h>
+
++#include <time.h>
++
+ #include "arg.h"
+ #include "util.h"
+
+ char *argv0;
+
++time_t lasttouched;
++int runflag = 0;
++
+ enum {
+ INIT,
+ INPUT,
+_AT_@ -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);
+ }
++
++ time_t currenttime;
++ time(¤ttime);
++
++ if (currenttime >= lasttouched + timeoffset){
++ if (!runonce || !runflag){
++ runflag = 1;
++ system(command);
++ }
++ }
+ }
+ }
+
+_AT_@ -229,6 +244,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
+ XSetWindowAttributes wa;
+ Cursor invisible;
+
++ time(&lasttouched);
++
+ if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(struct lock))))
+ return NULL;
+
Received on Sun Oct 02 2022 - 00:15:25 CEST
This archive was generated by hypermail 2.3.0
: Sun Oct 02 2022 - 00:24:55 CEST