mirror of
https://github.com/redstrate/LauncherTweaks.git
synced 2025-05-20 17:37:46 +00:00
30 lines
646 B
Rust
30 lines
646 B
Rust
|
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()
|
||
|
}
|