From a75729a759108ae672d8d1cfcc6252a6b680ef1f Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 23 Nov 2026 17:53:35 -0700 Subject: begin to stub out an I3 facility identifying the socket turns out to be quite some work Force-Push: yes Change-Id: I747e89410efdc38cb13d3be2ad3e985c1cdc9952 --- src/xdg.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/xdg.rs (limited to 'src/xdg.rs') diff --git a/src/xdg.rs b/src/xdg.rs new file mode 100644 index 0000000..2c130e7 --- /dev/null +++ b/src/xdg.rs @@ -0,0 +1,27 @@ +use crate::Result; + +use std::path::PathBuf; + + +/* The spec does not suggest a default for this one, merely saying that + * applications should fall back to something else. So, we return an Option to + * allow our caller to worry about that. + */ +pub fn xdg_runtime_directory() -> Result> { + if let Ok(mut path) = std::env::var("XDG_RUNTIME_DIR") { + /* As nice as it would be to use a portable interface for this, Rust + * doesn't have a stable one yet. In fact, we barely have visibility into + * it at all once we convert to a path. + * + * Oh well. Fuck Microsoft anyway. + */ + if !path.ends_with("/") { + path.push_str("/"); + } + + Ok(Some(PathBuf::from(path))) + } else { + Ok(None) + } +} + -- cgit 1.4.1