From 38ba551031af373a37bed89111ed6f139fc3d81d Mon Sep 17 00:00:00 2001 From: Nikita Zlobin Date: Tue, 15 Apr 2025 21:23:32 +0500 Subject: [PATCH] Fix session ID detection It's rather illborn to use client's X connection id in place of X session id. However, I'm not sure, that XDG_SESSION_ID is set everywhere. DISPLAY could be good replacement for missing session ID (and could be not as well). --- src/skippy.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/skippy.c b/src/skippy.c index fc0a40d..7d67d8d 100644 --- a/src/skippy.c +++ b/src/skippy.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include bool debuglog = false; @@ -2322,7 +2324,14 @@ load_config_file(session_t *ps) for (int num = uid; num >= 10; num /= 10) pipeStrLen0++; - int xid = XConnectionNumber(ps->dpy); + char *xid_env = getenv("XDG_SESSION_ID"); + if (! xid_env) { + xid_env = strrchr(getenv("DISPLAY"), ':'); + if (xid_env) + xid_env++; + } + + int xid = atoi(xid_env); for (int num = xid; num >= 10; num /= 10) pipeStrLen0++; -- 2.48.1