chiark / gitweb /
Try using xdg to get the config directory location.
authorSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 11:58:04 +0000 (11:58 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 23 Dec 2023 11:58:04 +0000 (11:58 +0000)
Cargo.toml
src/main.rs

index 10b6e229fe14fd8d4020508e9e8f8c99fda9d745..5f6a2c0585f5c7232c67675b3e29d15caff582a9 100644 (file)
@@ -12,3 +12,4 @@ reqwest = { version = "0.11.23", features = ["blocking"] }
 serde = { version = "1.0.193", features = ["derive"] }
 serde_json = "1.0.108"
 unicode-width = "0.1.5"
+xdg = "2.5.2"
index f562a7404b301ac90e07256c47f5220a90115488..fd695d6c80a57cc70bbb913ae98f3c74a8dfc5e0 100644 (file)
@@ -2,8 +2,10 @@
 use std::io::Read;
 
 fn main() {
-    let auth = std::fs::read_to_string(
-        "/home/simon/.config/mastodonochrome/auth").unwrap();
+    let xdg_dirs = xdg::BaseDirectories::with_prefix("mastodonochrome")
+        .unwrap();
+    let authfile = xdg_dirs.get_config_file("auth");
+    let auth = std::fs::read_to_string(authfile).unwrap();
     let auth: serde_json::Value = serde_json::from_str(&auth).unwrap();
     let auth = &auth["user_token"].as_str().unwrap();