this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: persist card directory across restarts

Save chosen dir to ~/.config/tala/dir on change; load it on startup
with priority: CLI arg > saved config > cwd.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

+23
+23
crates/tala/src/main.rs
··· 9 9 const FAVICON: Asset = asset!("/assets/favicon.ico"); 10 10 const MAIN_CSS: Asset = asset!("/assets/main.css"); 11 11 12 + fn config_dir_file() -> Option<PathBuf> { 13 + let home = std::env::var("HOME").ok()?; 14 + Some(PathBuf::from(home).join(".config").join("tala").join("dir")) 15 + } 16 + 17 + fn load_saved_dir() -> Option<PathBuf> { 18 + let path = config_dir_file()?; 19 + let s = std::fs::read_to_string(path).ok()?; 20 + let p = PathBuf::from(s.trim()); 21 + if p.is_dir() { Some(p) } else { None } 22 + } 23 + 24 + fn persist_dir(path: &PathBuf) { 25 + if let Some(f) = config_dir_file() { 26 + if let Some(parent) = f.parent() { 27 + let _ = std::fs::create_dir_all(parent); 28 + } 29 + let _ = std::fs::write(&f, path.display().to_string()); 30 + } 31 + } 32 + 12 33 /// Directory containing cards.typ and images/. 13 34 static CARD_DIR: GlobalSignal<PathBuf> = Signal::global(|| { 14 35 let dir = std::env::args() 15 36 .nth(1) 16 37 .map(PathBuf::from) 38 + .or_else(load_saved_dir) 17 39 .unwrap_or_else(|| std::env::current_dir().expect("cwd")); 18 40 let dir = std::fs::canonicalize(&dir).unwrap_or(dir); 19 41 let _ = std::fs::create_dir_all(dir.join("images")); ··· 31 53 fn set_card_dir(path: PathBuf) { 32 54 let path = std::fs::canonicalize(&path).unwrap_or(path); 33 55 let _ = std::fs::create_dir_all(path.join("images")); 56 + persist_dir(&path); 34 57 *CARD_DIR.write() = path; 35 58 } 36 59