diff --git a/Makefile b/Makefile index 127d3b2..bcc9cef 100644 --- a/Makefile +++ b/Makefile @@ -6,3 +6,7 @@ release: ln -sf target/release/ame . clean: rm -rf target/ Cargo.lock ame +install: + sudo cp ame.toml /etc/ame.toml + sudo cp target/release/ame /usr/bin/ame + mkdir ~/.cache/ame \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e9dd986..fd45d89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,8 +35,8 @@ fn main() { let mut confile = File::open("/etc/ame.toml").expect("Unable to open the Config file, did you delete ame.toml from /etc/??"); let mut config = String::new(); let conftostring = fs::read_to_string("/etc/ame.toml").expect("unable to open config file!"); - let configfile: General = toml::from_str(r#" - cache = "/home/user/.cache/ame" + let defaultconfig = format!(r#" + cache = "{}/.cache/ame" [backends] pacman = true @@ -48,8 +48,9 @@ fn main() { noconfirm = false [aur] - clone_path = "/home/user/.cache/ame" - "#).unwrap(); + clone_path = "{}/.cache/ame" + "#, std::env::var("HOME").unwrap(), std::env::var("HOME").unwrap()); + let configfile: General = toml::from_str(&defaultconfig).unwrap(); if conftostring != "" { confile.read_to_string(&mut config).expect("Unable to read the Config file"); let configfile: General = toml::from_str(&config).unwrap(); diff --git a/src/mods/config.rs b/src/mods/config.rs index 75465ab..782b6fe 100644 --- a/src/mods/config.rs +++ b/src/mods/config.rs @@ -36,8 +36,8 @@ pub fn printconfig() { let mut confile = File::open("/etc/ame.toml").expect("Unable to open the Config file, did you delete ame.toml from /etc/??"); let mut config = String::new(); let conftostring = fs::read_to_string("/etc/ame.toml").expect("unable to open config file!"); - let configfile: General = toml::from_str(r#" - cache = "/home/user/.cache/ame" + let defaultconfig = format!(r#" + cache = "{}/.cache/ame" [backends] pacman = true @@ -49,8 +49,9 @@ pub fn printconfig() { noconfirm = false [aur] - clone_path = "/home/user/.cache/ame" - "#).unwrap(); + clone_path = "{}/.cache/ame" + "#, std::env::var("HOME").unwrap(), std::env::var("HOME").unwrap()); + let configfile: General = toml::from_str(&defaultconfig).unwrap(); if conftostring != "" { confile.read_to_string(&mut config).expect("Unable to read the Config file"); let configfile: General = toml::from_str(&config).unwrap();