1
0
mirror of https://github.com/mfontanini/presenterm.git synced 2026-09-01 23:33:21 -06:00

Merge 4393702f778967910cff4ade1faa06f081bf61ac into 5f8add11a24af9d257fd18da48c8004dd9c516f8

This commit is contained in:
abdellah hariti 2026-05-25 10:41:34 +08:00 committed by GitHub
commit 813053ccd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 6 deletions

View File

@ -4,7 +4,7 @@ _presenterm_ allows you to customize its behavior via a configuration file. This
custom themes, in the following directories:
* `$XDG_CONFIG_HOME/presenterm/` if that environment variable is defined, otherwise:
* `~/.config/presenterm/` in Linux.
* `~/.config/presenterm/` in Linux or macOS.
* `~/Library/Application Support/presenterm/` in macOS.
* `~/AppData/Roaming/presenterm/config/` in Windows.

View File

@ -155,7 +155,7 @@ fn create_splash() -> String {
v{crate_version}
A terminal slideshow tool
A terminal slideshow tool
@mfontanini/presenterm
"#,
)
@ -171,13 +171,32 @@ struct Customizations {
impl Customizations {
fn load(config_file_path: Option<PathBuf>, cwd: &Path) -> Result<Self, Box<dyn std::error::Error>> {
let get_default_config_dir = || -> Result<PathBuf, Box<dyn std::error::Error>> {
let Some(project_dirs) = ProjectDirs::from("", "", "presenterm") else {
return Ok(Default::default());
};
Ok(project_dirs.config_dir().into())
};
let configs_path: PathBuf = match env::var("XDG_CONFIG_HOME") {
Ok(path) => Path::new(&path).join("presenterm"),
Err(_) => {
let Some(project_dirs) = ProjectDirs::from("", "", "presenterm") else {
return Ok(Default::default());
};
project_dirs.config_dir().into()
#[cfg(target_os = "macos")]
if let Ok(home) = env::var("HOME") {
let xdg_path = Path::new(&home).join(".config").join("presenterm");
if xdg_path.exists() {
println!("Using Home config");
xdg_path
} else {
get_default_config_dir()?
}
} else {
get_default_config_dir()?
}
#[cfg(not(target_os = "macos"))]
{
get_default_config_dir()?
}
}
};
let themes_path = configs_path.join("themes");