1use std::fs;
2use std::path::PathBuf;
3
4fn get_config_path() -> Option<PathBuf> {
5 dirs::config_dir().map(|mut path| {
6 path.push("nmrs");
7 fs::create_dir_all(&path).ok()?;
8 path.push("theme");
9 Some(path)
10 })?
11}
12
13pub fn save_theme(name: &str) {
15 if let Some(path) = get_config_path() {
16 let _ = fs::write(path, name);
17 }
18}
19
20pub fn load_theme() -> Option<String> {
23 get_config_path()
24 .and_then(|path| fs::read_to_string(path).ok())
25 .map(|s| s.trim().to_string())
26}