diff options
author | Alberto Corona <ac@albertocorona.com> | 2017-01-07 15:19:30 -0600 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-01-09 09:23:32 -0800 |
commit | 987b8555def9b321d8388d7ca8290d214bc51c4a (patch) | |
tree | fcd79875adb6fc0430c3beb61b5db651a6295b9a /src/config.rs | |
parent | 2fa271419c4765f7758dcf336fe0b913c12c18a6 (diff) | |
download | alacritty-987b8555def9b321d8388d7ca8290d214bc51c4a.tar.gz alacritty-987b8555def9b321d8388d7ca8290d214bc51c4a.zip |
Conform to XDG spec for configuration
- Use $XDG_CONFIG_HOME/alacritty/alacritty.yml for loading the
configuration file falling back to $HOME/.config/alacritty/alacritty.yml
- Closes #203
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs index 4511b227..706f1d01 100644 --- a/src/config.rs +++ b/src/config.rs @@ -811,19 +811,19 @@ impl Config { /// /// The config file is loaded from the first file it finds in this list of paths /// - /// 1. `$HOME/.config/alacritty.yml` - /// 2. `$HOME/.alacritty.yml` + /// 1. $XDG_CONFIG_HOME/alacritty/alacritty.yml + /// 2. $HOME/.config/alacritty/alacritty.yml pub fn load() -> Result<Config> { let home = env::var("HOME")?; // Try using XDG location by default - let path = ::xdg::BaseDirectories::new() + let path = ::xdg::BaseDirectories::with_prefix("alacritty") .ok() .and_then(|xdg| xdg.find_config_file("alacritty.yml")) .unwrap_or_else(|| { - // Fallback path: $HOME/.alacritty.yml + // Fallback path: $HOME/.config/alacritty/alacritty.yml let mut alt_path = PathBuf::from(&home); - alt_path.push(".alacritty.yml"); + alt_path.push(".config/alacritty/alacritty.yml"); alt_path }); @@ -831,7 +831,7 @@ impl Config { } pub fn write_defaults() -> io::Result<PathBuf> { - let path = ::xdg::BaseDirectories::new() + let path = ::xdg::BaseDirectories::with_prefix("alacritty") .map_err(|err| io::Error::new(io::ErrorKind::NotFound, ::std::error::Error::description(&err))) .and_then(|p| p.place_config_file("alacritty.yml"))?; File::create(&path)?.write_all(DEFAULT_ALACRITTY_CONFIG.as_bytes())?; |