commit bb763ba9865e36eb3b655051a8b73f4301da299b
parent 3fc1818219dc28817a0df53c2f0108b763941e74
Author: bakkeby <bakkeby@gmail.com>
Date: Sat, 15 Nov 2025 08:55:48 +0100
Adding visual unlock patch ref. #14
Diffstat:
4 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
@@ -26,6 +26,8 @@ slock tool, how to install it and how it works.
### Changelog:
+2025-11-15 - Added the visual unlock patch
+
2022-03-28 - Added the background image patch
2021-09-13 - Added the dwm logo patch
diff --git a/config.def.h b/config.def.h
@@ -137,7 +137,12 @@ static const int controlkeyclear = 0;
#if DPMS_PATCH
/* time in seconds before the monitor shuts down */
-static const int monitortime = 5;
+static int monitortime = 5;
+
+#if VISUAL_UNLOCK_PATCH
+/* time in seconds before the monitor shuts down, if visual_unlock is enabled */
+static const int monitortime_vu = 0;
+#endif // VISUAL_UNLOCK_PATCH
#endif // DPMS_PATCH
#if KEYPRESS_FEEDBACK_PATCH
diff --git a/patches.def.h b/patches.def.h
@@ -139,6 +139,13 @@
*/
#define UNLOCKSCREEN_PATCH 0
+/* This patch adds a command line argument -u that keeps the input locked but do not
+ * show the lock screen. The original patch simply combines the unlock screen patch and
+ * the DPMS patch. Enable DPMS_PATCH separately if you want DPMS.
+ * https://tools.suckless.org/slock/patches/visual-unlock-dpms/
+ */
+#define VISUAL_UNLOCK_PATCH 0
+
/* This patch adds the ability to get colors via Xresources.
* https://tools.suckless.org/slock/patches/xresources/
*/
diff --git a/slock.c b/slock.c
@@ -60,6 +60,10 @@ int runflag = 0;
static time_t locktime;
#endif // QUICKCANCEL_PATCH
+#if VISUAL_UNLOCK_PATCH
+int visual_unlock = 0;
+#endif // VISUAL_UNLOCK_PATCH
+
enum {
#if DWM_LOGO_PATCH && !BLUR_PIXELATED_SCREEN_PATCH
BACKGROUND,
@@ -587,7 +591,12 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
/* input is grabbed: we can lock the screen */
if (ptgrab == GrabSuccess && kbgrab == GrabSuccess) {
#if !UNLOCKSCREEN_PATCH
+ #if VISUAL_UNLOCK_PATCH
+ if (!visual_unlock)
+ XMapRaised(dpy, lock->win);
+ #else
XMapRaised(dpy, lock->win);
+ #endif // VISUAL_UNLOCK_PATCH
#endif // UNLOCKSCREEN_PATCH
if (rr->active)
XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
@@ -670,6 +679,11 @@ main(int argc, char **argv) {
}
return 0;
#endif // MESSAGE_PATCH | COLOR_MESSAGE_PATCH
+ #if VISUAL_UNLOCK_PATCH
+ case 'u':
+ visual_unlock = 1;
+ break;
+ #endif // VISUAL_UNLOCK_PATCH
default:
usage();
} ARGEND
@@ -749,6 +763,11 @@ main(int argc, char **argv) {
#if DPMS_PATCH
/* DPMS magic to disable the monitor */
+ #if VISUAL_UNLOCK_PATCH
+ if (visual_unlock)
+ monitortime = monitortime_vu;
+ #endif // VISUAL_UNLOCK_PATCH
+
if (!DPMSCapable(dpy))
die("slock: DPMSCapable failed\n");
if (!DPMSEnable(dpy))