diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-11-23 17:53:35 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-11-23 17:53:35 -0700 |
| commit | a75729a759108ae672d8d1cfcc6252a6b680ef1f (patch) | |
| tree | c23862c1b9c0b92f837ec21884c7928d78532d01 /src/xdg.rs | |
| parent | 2c3596229ea752110dff065528d3fda8e8ba95aa (diff) | |
begin to stub out an I3 facility
identifying the socket turns out to be quite some work Force-Push: yes Change-Id: I747e89410efdc38cb13d3be2ad3e985c1cdc9952
Diffstat (limited to 'src/xdg.rs')
| -rw-r--r-- | src/xdg.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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<Option<PathBuf>> { + 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) + } +} + |