add xdg configs

This commit is contained in:
Your Name 2025-11-06 20:07:16 +01:00
parent 136dad885e
commit 604d2e4134
3 changed files with 24 additions and 6 deletions

View file

@ -68,6 +68,15 @@ pub struct Configuration {
}
impl Configuration {
fn get_configuration_file() -> Result<File, Box<dyn std::error::Error>>
{
let xdg_dirs = xdg::BaseDirectories::new()?;
let config_file = xdg_dirs.find_config_file("unfettered-keyboard.yaml")
.ok_or(std::io::Error::new(std::io::ErrorKind::NotFound, "Config file not found"))?;
println!("test{:?}",config_file);
Ok(File::open(config_file)?)
}
fn load_evfb(&mut self, yaml: &Hash)
{
let height = yaml.get(&Yaml::String(String::from("height")));
@ -154,7 +163,7 @@ impl Configuration {
colors: KeyboardColors::default(),
};
if let Ok(file) = File::open("/etc/unfettered-keyboard.yaml") {
if let Ok(file) = Self::get_configuration_file() {
let yaml = YamlDecoder::read(file).decode()?;
let yaml = yaml[0].as_hash().expect("Top-level configuration should be a YAML mapping");