From e09024c60160f29515991eca6d97ea798dc78d69 Mon Sep 17 00:00:00 2001 From: Rafael Madriz Date: Sun, 12 Sep 2021 12:47:14 +0200 Subject: [PATCH] added ~ subsitution for the config, paths with ~/ work now --- ame.toml | 2 +- src/main.rs | 2 ++ src/mods/config.rs | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ame.toml b/ame.toml index 439eef5..9d31ea6 100644 --- a/ame.toml +++ b/ame.toml @@ -1,4 +1,4 @@ -cache = "/home/ali/.ame" +cache = "~/.cache/ame" [backends] pacman = true diff --git a/src/main.rs b/src/main.rs index bacaac9..ccfba35 100644 --- a/src/main.rs +++ b/src/main.rs @@ -42,6 +42,8 @@ fn main() { if fs::read_to_string("/etc/ame.toml").expect("unable to open config file! (/etc/ame.toml)") != "" { confile.read_to_string(&mut config).expect("Unable to read the Config file (/etc/ame.toml)"); + let homepath = std::env::var("HOME").unwrap(); + config=config.replace("~", &homepath); configfile = toml::from_str(&config).unwrap(); } diff --git a/src/mods/config.rs b/src/mods/config.rs index ff50d75..d995e3c 100644 --- a/src/mods/config.rs +++ b/src/mods/config.rs @@ -41,6 +41,8 @@ pub fn printconfig() { let mut configfile: General = toml::from_str(&defaultconfig).unwrap(); if fs::read_to_string("/etc/ame.toml").expect("unable to open config file! (/etc/ame.toml)") != "" { confile.read_to_string(&mut config).expect("Unable to read the Config file (/etc/ame.toml)"); + let homepath = std::env::var("HOME").unwrap(); + config=config.replace("~", &homepath); configfile = toml::from_str(&config).unwrap(); } println!("\