sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 0825ea76deded03e123bb6dccb304ecbede0e529
parent df45737a0d3f56d61ee0c28cfe72d0e4550daf24
Author: Rishvic Pushpakaran <rishvic@gmail.com>
Date:   Mon,  3 Aug 2026 10:55:47 +0530

[slock][patches][xss-lock] add patch

Diffstat:
Atools.suckless.org/slock/patches/xss-lock/index.md | 23+++++++++++++++++++++++
Atools.suckless.org/slock/patches/xss-lock/slock-xss-lock-1.7.diff | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/slock/patches/xss-lock/index.md b/tools.suckless.org/slock/patches/xss-lock/index.md @@ -0,0 +1,23 @@ +xss-lock +======== + +Description +----------- +xss-lock(1), when used with the `-l` option, coordinates locker activation with +the login manager using a delay lock (via a file descriptor). Any locker +application being used with xss-lock can communicate that locking is complete +by closing the file descriptor set in the `$XSS_SLEEP_LOCK_FD` environment +variable. This makes sure that suspend waits till the locker has started up. +Otherwise, the screen's contents may show up briefly for a short time after +waking up. + +This patch adds the ability in slock to detect if `$XSS_SLEEP_LOCK_FD` is set, +and if so, close the file descriptor once locking is complete. + +Download +-------- +* [slock-xss-lock-1.7.diff](slock-xss-lock-1.7.diff) + +Authors +------- +* Rishvic Pushpakaran <rishvic@gmail.com> diff --git a/tools.suckless.org/slock/patches/xss-lock/slock-xss-lock-1.7.diff b/tools.suckless.org/slock/patches/xss-lock/slock-xss-lock-1.7.diff @@ -0,0 +1,87 @@ +diff -up a/slock.c b/slock.c +--- a/slock.c 2026-07-28 03:28:03.120285888 +0530 ++++ b/slock.c 2026-08-03 11:20:35.223992495 +0530 +@@ -6,7 +6,9 @@ + + #include <ctype.h> + #include <errno.h> ++#include <fcntl.h> + #include <grp.h> ++#include <limits.h> + #include <pwd.h> + #include <stdarg.h> + #include <stdlib.h> +@@ -59,7 +61,6 @@ die(const char *errstr, ...) + } + + #ifdef __linux__ +-#include <fcntl.h> + #include <linux/oom.h> + + static void +@@ -301,6 +302,28 @@ lockscreen(Display *dpy, struct xrandr * + return NULL; + } + ++static int ++get_xss_sleep_lock_fd(void) ++{ ++ char *env_str, *end; ++ long env_val; ++ ++ env_str = getenv("XSS_SLEEP_LOCK_FD"); ++ if (!env_str || !*env_str) ++ return -1; ++ ++ errno = 0; ++ env_val = strtol(env_str, &end, 10); ++ if (errno || ++ *end || ++ (env_val < 0 || env_val > INT_MAX)) { ++ fprintf(stderr, "slock: strtol $XSS_SLEEP_LOCK_FD: %s\n", ++ errno ? strerror(errno) : "invalid value"); ++ return -1; ++ } ++ return (int)env_val; ++} ++ + static void + usage(void) + { +@@ -318,6 +341,7 @@ main(int argc, char **argv) { + const char *hash; + Display *dpy; + int s, nlocks, nscreens; ++ int lockfd; + + ARGBEGIN { + case 'v': +@@ -327,6 +351,18 @@ main(int argc, char **argv) { + usage(); + } ARGEND + ++ lockfd = get_xss_sleep_lock_fd(); ++ if (lockfd >= 0) { ++ int flags = fcntl(lockfd, F_GETFD); ++ if (flags < 0) { ++ fprintf(stderr, "slock: fcntl $XSS_SLEEP_LOCK_FD F_GETFD: %s\n", ++ strerror(errno)); ++ } else if (fcntl(lockfd, F_SETFD, flags | FD_CLOEXEC) == -1) { ++ fprintf(stderr, "slock: fcntl $XSS_SLEEP_LOCK_FD F_SETFD: %s\n", ++ strerror(errno)); ++ } ++ } ++ + /* validate drop-user and -group */ + errno = 0; + if (!(pwd = getpwnam(user))) +@@ -378,6 +414,9 @@ main(int argc, char **argv) { + if (nlocks != nscreens) + return 1; + ++ if (lockfd >= 0 && close(lockfd) < 0) ++ fprintf(stderr, "slock: close $XSS_SLEEP_LOCK_FD: %s\n", strerror(errno)); ++ + /* run post-lock command */ + if (argc > 0) { + pid_t pid;