git.lucas.co / cce-cloud
cloud storage client
git clone https://git.lucas.co/cce-cloud.git

commitab469b1ddf441dde76d32315963817b4ffef8722
parenta23a820500
authorLucas Galante <[email protected]>
date2026-07-14 20:37
fix: key the daemon socket by WAYLAND_DISPLAY

The socket was a per-uid singleton, so a second compositor session
(e.g. a nested one) either hijacked the running session's daemon —
its popups appeared on the wrong display — or stole the bind out from
under it. Include the display name in the socket path so each session
gets its own daemon.

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/main.rs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index f85e97e..f9fe97c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2833,10 +2833,13 @@ fn main() {
 
     let uid = unsafe { libc::getuid() };
     let socket_dir = format!("/run/user/{}", uid);
+    // Key the socket by display so a nested/second compositor session gets its
+    // own daemon instead of hijacking (or being hijacked by) another session's.
+    let display = std::env::var("WAYLAND_DISPLAY").unwrap_or_else(|_| "wayland-0".to_string());
     let socket_path = if std::path::Path::new(&socket_dir).exists() {
-        format!("{}/cce-cloud.socket", socket_dir)
+        format!("{}/cce-cloud-{}.socket", socket_dir, display)
     } else {
-        format!("/tmp/cce-cloud-{}.socket", uid)
+        format!("/tmp/cce-cloud-{}-{}.socket", uid, display)
     };
 
     if is_daemon {