From bb763ba9865e36eb3b655051a8b73f4301da299b Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 15 Nov 2025 08:55:48 +0100 Subject: [PATCH] Adding visual unlock patch ref. #14 --- README.md | 2 ++ config.def.h | 7 ++++++- patches.def.h | 7 +++++++ slock.c | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b3ce30b585536f191cd5231984e381245a5a6799..80b3de9a27d25f438ebbe4634195fc6d62b5e5ea 100644 --- 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 index 9f7baac1e113a059a1fc9d452b2607716f409568..adf82aec12c1247b67f44effa03efef42e8783fd 100644 --- 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 index ade6ed839e6d3afad2f5c32b247efcc96b422ab4..120fc90aa782bb9842a8a55f37c45a3193634b7f 100644 --- 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 index 0c34c02ece00a0f3401baa6de0067b52e0255541..e61e00072795ff83df9a75128731e8f5a8ff449e 100644 --- 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))