From bf630a4b572e937b56851cc1088e7563f64d0b34 Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Fri, 7 Aug 2026 16:29:20 +0200 Subject: [PATCH] fix(daemon): resolve outputs.ron from the user's passwd home The greeter daemon runs as root without HOME set, so xdg::BaseDirectories resolved the state dir against root's environment and never found the user's cosmic-comp output layout. The greeter therefore came up with the default monitor arrangement instead of the saved one. Resolve the home directory from the passwd entry of the user being described, read ~/.local/state/cosmic-comp/outputs.ron directly, and fall back to an empty list when the file is absent. Also revert the two version fields that the 1.3.0 bulk bump rewrote by mistake: greetd_ipc has no 1.3.0 release, and the crate version is kept at 0.1.0 to stay consistent with Cargo.lock so --locked builds work. Co-Authored-By: Claude Opus 5 (1M context) --- Cargo.lock | 5 +++-- Cargo.toml | 4 ++-- daemon/src/lib.rs | 38 ++++++++++++++++++++++++++++---------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c2ec85a..59b1f00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1094,7 +1094,7 @@ dependencies = [ [[package]] name = "cosmic-applets-config" -version = "1.0.15" +version = "1.3.0" dependencies = [ "cosmic-config", "serde", @@ -1167,6 +1167,7 @@ dependencies = [ [[package]] name = "cosmic-dbus-a11y" version = "0.1.0" +source = "git+https://github.com/pop-os/dbus-settings-bindings#eed01dd3609e90e3c8cd043656734c500956c793" dependencies = [ "zbus", ] @@ -1297,7 +1298,7 @@ dependencies = [ [[package]] name = "cosmic-randr-shell" -version = "0.1.0" +version = "1.3.0" dependencies = [ "kdl", "slotmap", diff --git a/Cargo.toml b/Cargo.toml index ff4eb29..170acb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmic-greeter" -version = "1.3.0" +version = "0.1.0" edition = "2024" [build-dependencies] @@ -88,7 +88,7 @@ image = { version = "0.25", default-features = false, features = [ ] } [dependencies.greetd_ipc] -version = "1.3.0" +version = "0.10.3" features = ["tokio-codec"] [features] diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs index 842aebe..e01885f 100644 --- a/daemon/src/lib.rs +++ b/daemon/src/lib.rs @@ -230,16 +230,34 @@ impl UserData { } }; - let xdg = xdg::BaseDirectories::new(); - self.kdl_output_lists = xdg - .get_state_home() - .map(|mut s| { - s.push("cosmic-comp/outputs.ron"); - let lists = randr::load_outputs(Some(&s)); - lists - .into_iter() - .map(|l| KdlDocument::from(l).to_string()) - .collect() + // Resolve the user's home directory from pwd (not HOME env var, since + // the daemon runs as root without HOME defined). Then load outputs.ron + // from ~/.local/state/cosmic-comp/outputs.ron for this specific user. + let output_path = pwd::Passwd::from_name(&self.name) + .ok() + .flatten() + .map(|u| { + let mut p = PathBuf::from(u.dir); + p.push(".local"); + p.push("state"); + p.push("cosmic-comp"); + p.push("outputs.ron"); + p + }); + self.kdl_output_lists = output_path + .as_ref() + .and_then(|p| { + if p.exists() { + let lists = randr::load_outputs(Some(p)); + Some( + lists + .into_iter() + .map(|l| KdlDocument::from(l).to_string()) + .collect(), + ) + } else { + None + } }) .unwrap_or_default();