feat: support user preview configuration and document UI

This commit is contained in:
2026-10-05 19:17:27 +05:30
parent ee6186ed0b
commit de8843471b
10 changed files with 210 additions and 80 deletions

View File

@@ -1,6 +1,6 @@
use std::{
collections::HashMap,
fs,
env, fs,
os::unix::fs::MetadataExt,
path::{Path, PathBuf},
};
@@ -9,6 +9,19 @@ use serde::Deserialize;
use crate::error::{Error, ResultExt};
pub const SYSTEM_CONFIG_PATH: &str = "/etc/latchd/config.toml";
const PROJECT_CONFIG_DIR: &str = "latchd";
const CONFIG_FILE: &str = "config.toml";
/// Returns the current user's configuration path.
pub fn user_config_path() -> Option<PathBuf> {
let base = env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.filter(|path| path.is_absolute())
.or_else(|| env::var_os("HOME").map(|home| PathBuf::from(home).join(".config")))?;
Some(base.join(PROJECT_CONFIG_DIR).join(CONFIG_FILE))
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct Config {