wip: use desktop file stem for app id
This commit is contained in:
parent
223c7855cf
commit
adc02df64f
12 changed files with 209 additions and 146 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use std::fmt::Debug;
|
||||
use std::fs::File;
|
||||
use crate::ID;
|
||||
use anyhow::anyhow;
|
||||
use serde::Deserialize;
|
||||
use std::fmt::Debug;
|
||||
use std::fs::File;
|
||||
use xdg::BaseDirectories;
|
||||
use crate::ID;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub enum TopLevelFilter {
|
||||
|
|
@ -19,13 +19,18 @@ pub struct AppListConfig {
|
|||
impl AppListConfig {
|
||||
/// load config with the provided name
|
||||
pub fn load() -> anyhow::Result<AppListConfig> {
|
||||
let file= match BaseDirectories::new().ok().and_then(|dirs| dirs.find_config_file(format!("{ID}/config.ron"))).and_then(|p| File::open(p).ok()) {
|
||||
let file = match BaseDirectories::new()
|
||||
.ok()
|
||||
.and_then(|dirs| dirs.find_config_file(format!("{ID}/config.ron")))
|
||||
.and_then(|p| File::open(p).ok())
|
||||
{
|
||||
Some(path) => path,
|
||||
_ => {
|
||||
anyhow::bail!("Failed to load config");
|
||||
}
|
||||
};
|
||||
|
||||
ron::de::from_reader::<_, AppListConfig>(file).map_err(|err| anyhow!("Failed to parse config file: {}", err))
|
||||
ron::de::from_reader::<_, AppListConfig>(file)
|
||||
.map_err(|err| anyhow!("Failed to parse config file: {}", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue