diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 32 | ||||
| -rw-r--r-- | src/lib.rs | 1 | 
2 files changed, 13 insertions, 20 deletions
| diff --git a/src/config.rs b/src/config.rs index 59b9f5ea..55e69c90 100644 --- a/src/config.rs +++ b/src/config.rs @@ -792,26 +792,18 @@ impl Config {      pub fn load() -> Result<Config> {          let home = env::var("HOME")?; -        // First path -        let mut path = PathBuf::from(&home); -        path.push(".config"); -        path.push("alacritty.yml"); - -        match Config::load_from(path) { -            Ok(c) => Ok(c), -            Err(e) => { -                match e { -                    Error::NotFound => { -                        // Fallback path -                        let mut alt_path = PathBuf::from(&home); -                        alt_path.push(".alacritty.yml"); - -                        Config::load_from(alt_path) -                    }, -                    _ => Err(e), -                } -            } -        } +        // Try using XDG location by default +        let path = ::xdg::BaseDirectories::new() +            .ok() +            .and_then(|xdg| xdg.find_config_file("alacritty.yml")) +            .unwrap_or_else(|| { +                // Fallback path: $HOME/.alacritty.yml +                let mut alt_path = PathBuf::from(&home); +                alt_path.push(".alacritty.yml"); +                alt_path +            }); + +        Config::load_from(path)      }      /// Get list of colors @@ -45,6 +45,7 @@ extern crate serde;  extern crate serde_json;  extern crate serde_yaml;  extern crate vte; +extern crate xdg;  #[macro_use]  extern crate bitflags; | 
