Skip to content

Commit 9b82bba

Browse files
authored
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.
1 parent 80d28ea commit 9b82bba

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/atuin-client/src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ impl Settings {
667667
let data_dir = atuin_common::utils::data_dir();
668668
let db_path = data_dir.join("history.db");
669669
let record_store_path = data_dir.join("records.db");
670-
let socket_path = data_dir.join("atuin.sock");
670+
let socket_path = atuin_common::utils::runtime_dir().join("atuin.sock");
671671

672672
let key_path = data_dir.join("key");
673673
let session_path = data_dir.join("session");

crates/atuin-common/src/utils.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ pub fn data_dir() -> PathBuf {
7777
data_dir.join("atuin")
7878
}
7979

80+
pub fn runtime_dir() -> PathBuf {
81+
std::env::var("XDG_RUNTIME_DIR").map_or_else(|_| data_dir(), PathBuf::from)
82+
}
83+
8084
pub fn dotfiles_cache_dir() -> PathBuf {
8185
// In most cases, this will be ~/.local/share/atuin/dotfiles/cache
8286
let data_dir = std::env::var("XDG_DATA_HOME")

0 commit comments

Comments
 (0)