wip: use toplevel protocols
This commit is contained in:
parent
647a402206
commit
560ebc0bf5
20 changed files with 1073 additions and 623 deletions
31
applets/cosmic-app-list/src/config.rs
Normal file
31
applets/cosmic-app-list/src/config.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use std::fmt::Debug;
|
||||
use std::fs::File;
|
||||
use anyhow::anyhow;
|
||||
use serde::Deserialize;
|
||||
use xdg::BaseDirectories;
|
||||
use crate::ID;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub enum TopLevelFilter {
|
||||
ActiveWorkspace,
|
||||
ConfiguredOutput,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
pub struct AppListConfig {
|
||||
pub filter_top_levels: Option<TopLevelFilter>,
|
||||
}
|
||||
|
||||
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()) {
|
||||
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))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue