1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Real support for placing config in XDG_CONFIG_HOME

Resolves #35.
This commit is contained in:
Joe Wilm 2017-01-02 20:04:46 -08:00
parent 8630185639
commit a105be82cf
5 changed files with 21 additions and 20 deletions

7
Cargo.lock generated
View file

@ -19,6 +19,7 @@ dependencies = [
"serde_json 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"vte 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1087,6 +1088,11 @@ dependencies = [
"pkg-config 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "xdg"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "xml-rs"
version = "0.3.5"
@ -1228,5 +1234,6 @@ dependencies = [
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
"checksum x11-dl 2.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4e4c7f0a7fb861a1bde4aa23bbda9509bda6b87de4d47c322f86e4c88241ebdd"
"checksum xdg 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77b831a5ba77110f438f0ac5583aafeb087f70432998ba6b7dcb1d32185db453"
"checksum xml-rs 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b15eed12692bd59d15e98ee7f8dc8408465b992d8ddb4d1672c24865132ec7"
"checksum yaml-rust 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e66366e18dc58b46801afbf2ca7661a9f59cc8c5962c29892b6039b4f86fa992"

View file

@ -25,6 +25,7 @@ vte = "0.1.2"
mio = "0.6"
serde_json = "*"
copypasta = { path = "./copypasta" }
xdg = "2.0.0"
clippy = { version = "0.0.104", optional = true }

View file

@ -85,7 +85,7 @@ many things (such as arrow keys) would not work.
Although it's possible the default configuration would work on your system,
you'll probably end up wanting to customize it anyhow. There is an
`alacritty.yml` at the git repository root. Copy this to either
`$HOME/.alacritty.yml` or `$HOME/.config/alacritty.yml` and run Alacritty.
`$HOME/.alacritty.yml` or `$XDG_CONFIG_HOME/alacritty.yml` and run Alacritty.
Many configuration options will take effect immediately upon saving changes to
the config file. The only exception is the `font` and `dpi` section which

View file

@ -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");
// 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
});
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),
}
}
}
Config::load_from(path)
}
/// Get list of colors

View file

@ -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;