Skip to main content

nmrs_gui/
theme_config.rs

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
13/// Save the selected theme *name* (e.g. "nord", "gruvbox", "dracula")
14pub fn save_theme(name: &str) {
15    if let Some(path) = get_config_path() {
16        let _ = fs::write(path, name);
17    }
18}
19
20/// Load the previously selected theme.
21/// Returns Some("nord") or None if missing.
22pub 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}