[wiki] [sites] [slock][patches][xss-lock] add patch || Rishvic Pushpakaran

From: <git_AT_suckless.org>
Date: Mon, 03 Aug 2026 08:09:11 +0200

commit 0825ea76deded03e123bb6dccb304ecbede0e529
Author: Rishvic Pushpakaran <rishvic_AT_gmail.com>
Date: Mon Aug 3 10:55:47 2026 +0530

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

diff --git a/tools.suckless.org/slock/patches/xss-lock/index.md b/tools.suckless.org/slock/patches/xss-lock/index.md
new file mode 100644
index 00000000..1940e1c4
--- /dev/null
+++ b/tools.suckless.org/slock/patches/xss-lock/index.md
_AT_@ -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_AT_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
new file mode 100644
index 00000000..b89751c2
--- /dev/null
+++ b/tools.suckless.org/slock/patches/xss-lock/slock-xss-lock-1.7.diff
_AT_@ -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
+_AT_@ -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>
+_AT_@ -59,7 +61,6 @@ die(const char *errstr, ...)
+ }
+
+ #ifdef __linux__
+-#include <fcntl.h>
+ #include <linux/oom.h>
+
+ static void
+_AT_@ -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
",
++ errno ? strerror(errno) : "invalid value");
++ return -1;
++ }
++ return (int)env_val;
++}
++
+ static void
+ usage(void)
+ {
+_AT_@ -318,6 +341,7 @@ main(int argc, char **argv) {
+ const char *hash;
+ Display *dpy;
+ int s, nlocks, nscreens;
++ int lockfd;
+
+ ARGBEGIN {
+ case 'v':
+_AT_@ -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
",
++ strerror(errno));
++ } else if (fcntl(lockfd, F_SETFD, flags | FD_CLOEXEC) == -1) {
++ fprintf(stderr, "slock: fcntl $XSS_SLEEP_LOCK_FD F_SETFD: %s
",
++ strerror(errno));
++ }
++ }
++
+ /* validate drop-user and -group */
+ errno = 0;
+ if (!(pwd = getpwnam(user)))
+_AT_@ -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
", strerror(errno));
++
+ /* run post-lock command */
+ if (argc > 0) {
+ pid_t pid;
Received on Mon Aug 03 2026 - 08:09:11 CEST

This archive was generated by hypermail 2.3.0 : Mon Aug 03 2026 - 08:12:49 CEST