From 9b82bba53f3e9eab26eb9af700027342d8a02ce5 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Thu, 20 Jun 2024 10:28:00 +0100 Subject: feat(daemon): follow XDG_RUNTIME_DIR if set (#2171) If XDG_RUNTIME_DIR is set, put the socket file there. If not, default to storing it in our data dir. We cannot default to a path such as /run/user/$UID/ because it does not exist on all systems. Any system running systemd will set this var by default, and ensure that the directory it points to is correctly setup. --- crates/atuin-common/src/utils.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'crates/atuin-common/src') diff --git a/crates/atuin-common/src/utils.rs b/crates/atuin-common/src/utils.rs index 3815085e..65f5efc4 100644 --- a/crates/atuin-common/src/utils.rs +++ b/crates/atuin-common/src/utils.rs @@ -77,6 +77,10 @@ pub fn data_dir() -> PathBuf { data_dir.join("atuin") } +pub fn runtime_dir() -> PathBuf { + std::env::var("XDG_RUNTIME_DIR").map_or_else(|_| data_dir(), PathBuf::from) +} + pub fn dotfiles_cache_dir() -> PathBuf { // In most cases, this will be ~/.local/share/atuin/dotfiles/cache let data_dir = std::env::var("XDG_DATA_HOME") -- cgit v1.3.1