diff --git a/Cargo.lock b/Cargo.lock index 72db6fe..6fb5957 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -630,6 +630,27 @@ dependencies = [ "walkdir", ] +[[package]] +name = "directories" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.59.0", +] + [[package]] name = "either" version = "1.13.0" @@ -1117,6 +1138,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1403,6 +1434,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "owo-colors" version = "3.5.0" @@ -1623,7 +1660,7 @@ dependencies = [ "rand_chacha", "simd_helpers", "system-deps", - "thiserror", + "thiserror 1.0.62", "v_frame", "wasm-bindgen", ] @@ -1678,6 +1715,17 @@ dependencies = [ "bitflags 2.6.0", ] +[[package]] +name = "redox_users" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +dependencies = [ + "getrandom", + "libredox", + "thiserror 2.0.11", +] + [[package]] name = "regex" version = "1.10.6" @@ -1914,6 +1962,7 @@ dependencies = [ "color-eyre", "console", "dircpy", + "directories", "fxhash", "image", "laurier", @@ -2134,7 +2183,7 @@ dependencies = [ "png", "resvg", "siphasher", - "thiserror", + "thiserror 1.0.62", "tiny-skia", "usvg", "xml-rs", @@ -2146,7 +2195,16 @@ version = "1.0.62" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2675633b1499176c2dff06b0856a27976a8f9d436737b4cf4f312d4d91d8bbb" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.62", +] + +[[package]] +name = "thiserror" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +dependencies = [ + "thiserror-impl 2.0.11", ] [[package]] @@ -2160,6 +2218,17 @@ dependencies = [ "syn 2.0.93", ] +[[package]] +name = "thiserror-impl" +version = "2.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.93", +] + [[package]] name = "thread_local" version = "1.1.8" diff --git a/Cargo.toml b/Cargo.toml index aec89f8..359c2de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ chrono = "0.4.39" clap = { version = "4.5.26", features = ["derive"] } color-eyre = "0.6.3" console = "0.15.10" +directories = "6.0.0" fxhash = "0.2.1" image = "0.25.5" laurier = "0.1.0" diff --git a/src/config.rs b/src/config.rs index 9cd5a68..ececb4d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -36,7 +36,7 @@ pub fn load() -> (UiConfig, GraphConfig, Option) { read_config_from_path(&user_path) } None => { - let default_path = xdg_config_file_path(); + let default_path = config_file_path(); if default_path.exists() { read_config_from_path(&default_path) } else { @@ -51,10 +51,14 @@ fn config_file_path_from_env() -> Option { env::var(CONFIG_FILE_ENV_NAME).ok().map(PathBuf::from) } -fn xdg_config_file_path() -> PathBuf { - xdg::BaseDirectories::with_prefix(APP_DIR_NAME) - .unwrap() - .get_config_file(CONFIG_FILE_NAME) +fn config_file_path() -> PathBuf { + use directories::BaseDirs; + + BaseDirs::new() + .expect("Couldn't get the base user directories!") + .config_dir() + .join(APP_DIR_NAME) + .join(CONFIG_FILE_NAME) } fn read_config_from_path(path: &Path) -> Config {