[wiki] [sites] [slock] Introducing quickcancel patch || Matthias Schoth

From: <git_AT_suckless.org>
Date: Wed, 16 Mar 2016 23:51:28 +0100

commit 862fbea54a1e191001302c3b4dbfc420f70b37ce
Author: Matthias Schoth <mschoth_AT_gmail.com>
Date: Wed Mar 16 23:51:01 2016 +0100

    [slock] Introducing quickcancel patch

diff --git a/tools.suckless.org/slock/patches/quickcancel.md b/tools.suckless.org/slock/patches/quickcancel.md
new file mode 100644
index 0000000..5e5e518
--- /dev/null
+++ b/tools.suckless.org/slock/patches/quickcancel.md
_AT_@ -0,0 +1,28 @@
+quickcancel
+===========
+
+Description
+-----------
+
+Allow slock to be cancelled by simple mouse movement within the
+first 3 seconds after starting.
+
+This is usefull if you forgot to disable `xautolock` during
+an activity that requires no input (e.g. reading text, watching video).
+
+Notes
+-----
+
+The number of seconds while the lock can be cancelled is configured
+in `config.h` via the `timetocancel` option.
+
+Download
+--------
+
+ * [slock-20160316-quickcancel.diff](slock-20160316-quickcancel.diff)
+
+Authors
+-------
+
+ * Matthias Schoth - mschoth_AT_gmail.com
+
diff --git a/tools.suckless.org/slock/patches/slock-20160316-quickcancel.diff b/tools.suckless.org/slock/patches/slock-20160316-quickcancel.diff
new file mode 100644
index 0000000..4317099
--- /dev/null
+++ b/tools.suckless.org/slock/patches/slock-20160316-quickcancel.diff
_AT_@ -0,0 +1,47 @@
+diff --git a/config.def.h b/config.def.h
+index eae2d9a..fbc8f13 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -6,3 +6,6 @@ static const char *colorname[NUMCOLS] = {
+
+ /* treat a cleared input like a wrong password */
+ static const int failonclear = 1;
++
++/* time to cancel lock with mouse movement in seconds */
++static const int timetocancel = 3;
+diff --git a/slock.c b/slock.c
+index c9cdee2..a187d7a 100644
+--- a/slock.c
++++ b/slock.c
+_AT_@ -12,6 +12,7 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <time.h>
+ #include <sys/types.h>
+ #include <X11/extensions/Xrandr.h>
+ #include <X11/keysym.h>
+_AT_@ -46,6 +47,7 @@ static Bool failure = False;
+ static Bool rr;
+ static int rrevbase;
+ static int rrerrbase;
++static time_t tim;
+
+ static void
+ die(const char *errstr, ...)
+_AT_@ -134,6 +136,7 @@ readpw(Display *dpy, const char *pws)
+ * utility. This way the user can easily set a customized DPMS
+ * timeout. */
+ while (running && !XNextEvent(dpy, &ev)) {
++ running = !((time(NULL) - tim < timetocancel) && (ev.type == MotionNotify));
+ if (ev.type == KeyPress) {
+ buf[0] = 0;
+ num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
+_AT_@ -261,6 +264,7 @@ lockscreen(Display *dpy, int screen)
+ if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) {
+ /* everything fine, we grabbed both inputs */
+ XSelectInput(dpy, lock->root, SubstructureNotifyMask);
++ tim = time(NULL);
+ return lock;
+ }
+ usleep(1000);
Received on Wed Mar 16 2016 - 23:51:28 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 17 2016 - 00:00:30 CET