1
Fork 0
mirror of https://github.com/redstrate/LauncherTweaks.git synced 2025-05-20 17:37:46 +00:00
launchertweaks/src/config.rs

30 lines
646 B
Rust
Raw Normal View History

2025-04-19 23:10:11 -04:00
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Config {
#[serde(default = "Config::default_launcher_url")]
pub launcher_url: String,
}
impl Default for Config {
fn default() -> Self {
Self {
launcher_url: Self::default_launcher_url(),
}
}
}
impl Config {
fn default_launcher_url() -> String {
"about:blank".to_string()
}
}
pub fn get_config() -> Config {
std::env::current_exe()
.ok()
.and_then(|p| std::fs::read_to_string(p.join("../launchertweaks.toml")).ok())
.and_then(|s| toml::from_str::<Config>(&s).ok())
.unwrap_or_default()
}