Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
refactor(config): default_state_path from cce_ui::config::cce_state_dir
`<state_home>/cce/state.json` as before, still None when there is no
home at all. The hand-rolled lookup took an empty $XDG_STATE_HOME at its
word and wrote /cce/state.json; cce-ui's state_home() (f31c86b) treats an
empty or relative one as unset, as the XDG spec says.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/server/config.rs | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/server/config.rs b/src/server/config.rs
index 6f20c841..47d951fe 100644
--- a/src/server/config.rs
+++ b/src/server/config.rs
@@ -1298,14 +1298,11 @@ pub fn default_config_path() -> Option<String> {
}
}
+/// `<state_home>/cce/state.json`; `None` when neither `$XDG_STATE_HOME` nor
+/// `$HOME` is set, rather than a path relative to wherever we were started.
pub fn default_state_path() -> Option<String> {
- if let Ok(xdg_state_home) = std::env::var("XDG_STATE_HOME") {
- Some(format!("{}/cce/state.json", xdg_state_home))
- } else if let Ok(home) = std::env::var("HOME") {
- Some(format!("{}/.local/state/cce/state.json", home))
- } else {
- None
- }
+ let path = cce_ui::config::cce_state_dir().join("state.json");
+ path.is_absolute().then(|| path.to_string_lossy().into_owned())
}
fn expand_env_vars(s: &str) -> String {